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


crypto/x509/x509_vfy.c:2690:1: start of procedure build_chain()
2688.   }
2689.   
2690. > static int build_chain(X509_STORE_CTX *ctx)
2691.   {
2692.       struct dane_st *dane = (struct dane_st *)ctx->dane;

crypto/x509/x509_vfy.c:2692:5: 
2690.   static int build_chain(X509_STORE_CTX *ctx)
2691.   {
2692. >     struct dane_st *dane = (struct dane_st *)ctx->dane;
2693.       int num = sk_X509_num(ctx->chain);
2694.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2693:5: 
2691.   {
2692.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2693. >     int num = sk_X509_num(ctx->chain);
2694.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2695.       int ss = cert_self_signed(cert);

include/openssl/x509.h:169:1: start of procedure sk_X509_num()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* 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:169:1: return from a call to sk_X509_num
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2694:5: 
2692.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2693.       int num = sk_X509_num(ctx->chain);
2694. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2695.       int ss = cert_self_signed(cert);
2696.       STACK_OF(X509) *sktmp = NULL;

include/openssl/x509.h:169:1: start of procedure sk_X509_value()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* 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:169:1: return from a call to sk_X509_value
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2695:5: 
2693.       int num = sk_X509_num(ctx->chain);
2694.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2695. >     int ss = cert_self_signed(cert);
2696.       STACK_OF(X509) *sktmp = NULL;
2697.       unsigned int search;

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

crypto/x509/x509_vfy.c:161:5: Skipping X509_check_purpose(): empty list of specs
  159.        * parse errors, rather than memory pressure!
  160.        */
  161.       X509_check_purpose(x, -1, 0);
             ^
  162.       if (x->ex_flags & EXFLAG_SS)
  163.           return 1;

crypto/x509/x509_vfy.c:162:9: 
  160.        */
  161.       X509_check_purpose(x, -1, 0);
  162. >     if (x->ex_flags & EXFLAG_SS)
  163.           return 1;
  164.       else
