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


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

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

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

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

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_num()
    275.   }
    276.   
    277. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)

crypto/stack/stack.c:279:9: Taking true branch
    277.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)
                   ^
    280.           return -1;
    281.       return st->num;

crypto/stack/stack.c:280:9: 
    278.   {
    279.       if (st == NULL)
    280. >         return -1;
    281.       return st->num;
    282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_num
    280.           return -1;
    281.       return st->num;
    282. > }
    283.   
    284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

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

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

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

crypto/stack/stack.c:284:1: start of procedure OPENSSL_sk_value()
    282.   }
    283.   
    284. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:286:9: Taking true branch
    284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    287.           return NULL;
    288.       return (void *)st->data[i];

crypto/stack/stack.c:287:9: 
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)
    287. >         return NULL;
    288.       return (void *)st->data[i];
    289.   }

crypto/stack/stack.c:289:1: return from a call to OPENSSL_sk_value
    287.           return NULL;
    288.       return (void *)st->data[i];
    289. > }
    290.   
    291.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

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

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

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

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

crypto/x509/x509_vfy.c:117:9: 
  115.        */
  116.       X509_check_purpose(x, -1, 0);
  117. >     if (x->ex_flags & EXFLAG_SS)
  118.           return 1;
  119.       else
