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


crypto/x509/x509_vfy.c:2830:1: start of procedure build_chain()
2828.   }
2829.   
2830. > static int build_chain(X509_STORE_CTX *ctx)
2831.   {
2832.       SSL_DANE *dane = ctx->dane;

crypto/x509/x509_vfy.c:2832:5: 
2830.   static int build_chain(X509_STORE_CTX *ctx)
2831.   {
2832. >     SSL_DANE *dane = ctx->dane;
2833.       int num = sk_X509_num(ctx->chain);
2834.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2833:5: 
2831.   {
2832.       SSL_DANE *dane = ctx->dane;
2833. >     int num = sk_X509_num(ctx->chain);
2834.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2835.       int ss = cert_self_signed(cert);

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

crypto/stack/stack.c:359:1: start of procedure OPENSSL_sk_num()
    357.   }
    358.   
    359. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361.       return st == NULL ? -1 : st->num;

crypto/stack/stack.c:361:12: Condition is true
    359.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361.       return st == NULL ? -1 : st->num;
                      ^
    362.   }
    363.   

crypto/stack/stack.c:361:5: 
    359.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361. >     return st == NULL ? -1 : st->num;
    362.   }
    363.   

crypto/stack/stack.c:362:1: return from a call to OPENSSL_sk_num
    360.   {
    361.       return st == NULL ? -1 : st->num;
    362. > }
    363.   
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

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

crypto/x509/x509_vfy.c:2834:5: 
2832.       SSL_DANE *dane = ctx->dane;
2833.       int num = sk_X509_num(ctx->chain);
2834. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2835.       int ss = cert_self_signed(cert);
2836.       STACK_OF(X509) *sktmp = NULL;

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

crypto/stack/stack.c:364:1: start of procedure OPENSSL_sk_value()
    362.   }
    363.   
    364. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:366:9: Taking true branch
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    367.           return NULL;
    368.       return (void *)st->data[i];

crypto/stack/stack.c:367:9: 
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
    367. >         return NULL;
    368.       return (void *)st->data[i];
    369.   }

crypto/stack/stack.c:369:1: return from a call to OPENSSL_sk_value
    367.           return NULL;
    368.       return (void *)st->data[i];
    369. > }
    370.   
    371.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

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

crypto/x509/x509_vfy.c:2835:5: 
2833.       int num = sk_X509_num(ctx->chain);
2834.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2835. >     int ss = cert_self_signed(cert);
2836.       STACK_OF(X509) *sktmp = NULL;
2837.       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: Skipping X509_check_purpose(): empty list of specs
  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/x509/x509_vfy.c:116:9: 
  114.        */
  115.       X509_check_purpose(x, -1, 0);
  116. >     if (x->ex_flags & EXFLAG_SS)
  117.           return 1;
  118.       else
