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


crypto/x509/x509_vfy.c:2631:1: start of procedure build_chain()
2629.   }
2630.   
2631. > static int build_chain(X509_STORE_CTX *ctx)
2632.   {
2633.       struct dane_st *dane = (struct dane_st *)ctx->dane;

crypto/x509/x509_vfy.c:2633:5: 
2631.   static int build_chain(X509_STORE_CTX *ctx)
2632.   {
2633. >     struct dane_st *dane = (struct dane_st *)ctx->dane;
2634.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2635.       int num = sk_X509_num(ctx->chain);

crypto/x509/x509_vfy.c:2634:5: 
2632.   {
2633.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2634. >     int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2635.       int num = sk_X509_num(ctx->chain);
2636.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2635:5: 
2633.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2634.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2635. >     int num = sk_X509_num(ctx->chain);
2636.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2637.       int ss = cert_self_signed(cert);

include/openssl/x509.h:170:1: start of procedure sk_X509_num()
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

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

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

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

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

include/openssl/x509.h:170:1: return from a call to sk_X509_num
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2636:5: 
2634.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2635.       int num = sk_X509_num(ctx->chain);
2636. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2637.       int ss = cert_self_signed(cert);
2638.       STACK_OF(X509) *sktmp = NULL;

include/openssl/x509.h:170:1: start of procedure sk_X509_value()
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

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

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

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

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

include/openssl/x509.h:170:1: return from a call to sk_X509_value
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:2637:5: 
2635.       int num = sk_X509_num(ctx->chain);
2636.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2637. >     int ss = cert_self_signed(cert);
2638.       STACK_OF(X509) *sktmp = NULL;
2639.       unsigned int search;

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

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

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