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


crypto/x509/x509_vfy.c:2867:1: start of procedure build_chain()
2865.   }
2866.   
2867. > static int build_chain(X509_STORE_CTX *ctx)
2868.   {
2869.       SSL_DANE *dane = ctx->dane;

crypto/x509/x509_vfy.c:2869:5: 
2867.   static int build_chain(X509_STORE_CTX *ctx)
2868.   {
2869. >     SSL_DANE *dane = ctx->dane;
2870.       int num = sk_X509_num(ctx->chain);
2871.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2870:5: 
2868.   {
2869.       SSL_DANE *dane = ctx->dane;
2870. >     int num = sk_X509_num(ctx->chain);
2871.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2872.       int ss = cert_self_signed(cert);

include/openssl/x509.h:98:1: start of procedure sk_X509_num()
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:265:1: start of procedure OPENSSL_sk_num()
    263.   }
    264.   
    265. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    266.   {
    267.       if (st == NULL)

crypto/stack/stack.c:267:9: Taking true branch
    265.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    266.   {
    267.       if (st == NULL)
                   ^
    268.           return -1;
    269.       return st->num;

crypto/stack/stack.c:268:9: 
    266.   {
    267.       if (st == NULL)
    268. >         return -1;
    269.       return st->num;
    270.   }

crypto/stack/stack.c:270:1: return from a call to OPENSSL_sk_num
    268.           return -1;
    269.       return st->num;
    270. > }
    271.   
    272.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509.h:98:1: return from a call to sk_X509_num
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2871:5: 
2869.       SSL_DANE *dane = ctx->dane;
2870.       int num = sk_X509_num(ctx->chain);
2871. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2872.       int ss = cert_self_signed(cert);
2873.       STACK_OF(X509) *sktmp = NULL;

include/openssl/x509.h:98:1: start of procedure sk_X509_value()
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:272:1: start of procedure OPENSSL_sk_value()
    270.   }
    271.   
    272. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:274:9: Taking true branch
    272.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    275.           return NULL;
    276.       return st->data[i];

crypto/stack/stack.c:275:9: 
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)
    275. >         return NULL;
    276.       return st->data[i];
    277.   }

crypto/stack/stack.c:277:1: return from a call to OPENSSL_sk_value
    275.           return NULL;
    276.       return st->data[i];
    277. > }
    278.   
    279.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)

include/openssl/x509.h:98:1: return from a call to sk_X509_value
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2872:5: 
2870.       int num = sk_X509_num(ctx->chain);
2871.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2872. >     int ss = cert_self_signed(cert);
2873.       STACK_OF(X509) *sktmp = NULL;
2874.       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);
