crypto/x509/x509_vfy.c:2815: error: NULL_DEREFERENCE
  pointer `cert` last assigned on line 2814 could be null and is dereferenced by call to `cert_self_signed()` at line 2815, column 14.
Showing all 21 steps of the trace


crypto/x509/x509_vfy.c:2810:1: start of procedure build_chain()
2808.   }
2809.   
2810. > static int build_chain(X509_STORE_CTX *ctx)
2811.   {
2812.       SSL_DANE *dane = ctx->dane;

crypto/x509/x509_vfy.c:2812:5: 
2810.   static int build_chain(X509_STORE_CTX *ctx)
2811.   {
2812. >     SSL_DANE *dane = ctx->dane;
2813.       int num = sk_X509_num(ctx->chain);
2814.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2813:5: 
2811.   {
2812.       SSL_DANE *dane = ctx->dane;
2813. >     int num = sk_X509_num(ctx->chain);
2814.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2815.       int ss = cert_self_signed(cert);

include/openssl/x509.h:104:1: start of procedure sk_X509_num()
  102.   typedef struct x509_cinf_st X509_CINF;
  103.   
  104. > DEFINE_STACK_OF(X509)
  105.   
  106.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:270:1: start of procedure OPENSSL_sk_num()
    268.   }
    269.   
    270. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    271.   {
    272.       if (st == NULL)

crypto/stack/stack.c:272:9: Taking true branch
    270.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    271.   {
    272.       if (st == NULL)
                   ^
    273.           return -1;
    274.       return st->num;

crypto/stack/stack.c:273:9: 
    271.   {
    272.       if (st == NULL)
    273. >         return -1;
    274.       return st->num;
    275.   }

crypto/stack/stack.c:275:1: return from a call to OPENSSL_sk_num
    273.           return -1;
    274.       return st->num;
    275. > }
    276.   
    277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509.h:104:1: return from a call to sk_X509_num
  102.   typedef struct x509_cinf_st X509_CINF;
  103.   
  104. > DEFINE_STACK_OF(X509)
  105.   
  106.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2814:5: 
2812.       SSL_DANE *dane = ctx->dane;
2813.       int num = sk_X509_num(ctx->chain);
2814. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2815.       int ss = cert_self_signed(cert);
2816.       STACK_OF(X509) *sktmp = NULL;

include/openssl/x509.h:104:1: start of procedure sk_X509_value()
  102.   typedef struct x509_cinf_st X509_CINF;
  103.   
  104. > DEFINE_STACK_OF(X509)
  105.   
  106.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_value()
    275.   }
    276.   
    277. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:279:9: Taking true branch
    277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    280.           return NULL;
    281.       return st->data[i];

crypto/stack/stack.c:280:9: 
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)
    280. >         return NULL;
    281.       return st->data[i];
    282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_value
    280.           return NULL;
    281.       return st->data[i];
    282. > }
    283.   
    284.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)

include/openssl/x509.h:104:1: return from a call to sk_X509_value
  102.   typedef struct x509_cinf_st X509_CINF;
  103.   
  104. > DEFINE_STACK_OF(X509)
  105.   
  106.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2815:5: 
2813.       int num = sk_X509_num(ctx->chain);
2814.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2815. >     int ss = cert_self_signed(cert);
2816.       STACK_OF(X509) *sktmp = NULL;
2817.       unsigned int search;

crypto/x509/x509_vfy.c:108:1: start of procedure cert_self_signed()
  106.   
  107.   /* Return 1 is a certificate is self signed */
  108. > static int cert_self_signed(X509 *x)
  109.   {
  110.       /*

crypto/x509/x509_vfy.c:115:5: 
  113.        * parse errors, rather than memory pressure!
  114.        */
  115. >     X509_check_purpose(x, -1, 0);
  116.       if (x->ex_flags & EXFLAG_SS)
  117.           return 1;

crypto/x509v3/v3_purp.c:77:1: start of procedure X509_check_purpose()
    75.    * things.
    76.    */
    77. > int X509_check_purpose(X509 *x, int id, int ca)
    78.   {
    79.       int idx;

crypto/x509v3/v3_purp.c:81:11: 
    79.       int idx;
    80.       const X509_PURPOSE *pt;
    81. >     if (!(x->ex_flags & EXFLAG_SET)) {
    82.           CRYPTO_THREAD_write_lock(x->lock);
    83.           x509v3_cache_extensions(x);
