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


crypto/x509/x509_vfy.c:2748:1: start of procedure build_chain()
2746.   }
2747.   
2748. > static int build_chain(X509_STORE_CTX *ctx)
2749.   {
2750.       SSL_DANE *dane = ctx->dane;

crypto/x509/x509_vfy.c:2750:5: 
2748.   static int build_chain(X509_STORE_CTX *ctx)
2749.   {
2750. >     SSL_DANE *dane = ctx->dane;
2751.       int num = sk_X509_num(ctx->chain);
2752.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2751:5: 
2749.   {
2750.       SSL_DANE *dane = ctx->dane;
2751. >     int num = sk_X509_num(ctx->chain);
2752.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2753.       int ss = cert_self_signed(cert);

include/openssl/x509.h:151:1: start of procedure sk_X509_num()
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:316:1: start of procedure sk_num()
    314.   }
    315.   
    316. > int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
    316.   int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)
                   ^
    319.           return -1;
    320.       return st->num;

crypto/stack/stack.c:319:9: 
    317.   {
    318.       if (st == NULL)
    319. >         return -1;
    320.       return st->num;
    321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
    319.           return -1;
    320.       return st->num;
    321. > }
    322.   
    323.   void *sk_value(const _STACK *st, int i)

include/openssl/x509.h:151:1: return from a call to sk_X509_num
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2752:5: 
2750.       SSL_DANE *dane = ctx->dane;
2751.       int num = sk_X509_num(ctx->chain);
2752. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2753.       int ss = cert_self_signed(cert);
2754.       STACK_OF(X509) *sktmp = NULL;

include/openssl/x509.h:151:1: start of procedure sk_X509_value()
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:323:1: start of procedure sk_value()
    321.   }
    322.   
    323. > void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:325:10: Taking true branch
    323.   void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
                    ^
    326.           return NULL;
    327.       return st->data[i];

crypto/stack/stack.c:326:9: 
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
    326. >         return NULL;
    327.       return st->data[i];
    328.   }

crypto/stack/stack.c:328:1: return from a call to sk_value
    326.           return NULL;
    327.       return st->data[i];
    328. > }
    329.   
    330.   void *sk_set(_STACK *st, int i, void *value)

include/openssl/x509.h:151:1: return from a call to sk_X509_value
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2753:5: 
2751.       int num = sk_X509_num(ctx->chain);
2752.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2753. >     int ss = cert_self_signed(cert);
2754.       STACK_OF(X509) *sktmp = NULL;
2755.       unsigned int search;

crypto/x509/x509_vfy.c:156:1: start of procedure cert_self_signed()
  154.   
  155.   /* Return 1 is a certificate is self signed */
  156. > static int cert_self_signed(X509 *x)
  157.   {
  158.       /*

crypto/x509/x509_vfy.c:163:5: 
  161.        * parse errors, rather than memory pressure!
  162.        */
  163. >     X509_check_purpose(x, -1, 0);
  164.       if (x->ex_flags & EXFLAG_SS)
  165.           return 1;

crypto/x509v3/v3_purp.c:126:1: start of procedure X509_check_purpose()
    124.    * things.
    125.    */
    126. > int X509_check_purpose(X509 *x, int id, int ca)
    127.   {
    128.       int idx;

crypto/x509v3/v3_purp.c:130:11: 
    128.       int idx;
    129.       const X509_PURPOSE *pt;
    130. >     if (!(x->ex_flags & EXFLAG_SET)) {
    131.           CRYPTO_THREAD_write_lock(x->lock);
    132.           x509v3_cache_extensions(x);
