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


crypto/x509/x509_vfy.c:2614:1: start of procedure build_chain()
2612.   }
2613.   
2614. > static int build_chain(X509_STORE_CTX *ctx)
2615.   {
2616.       struct dane_st *dane = (struct dane_st *)ctx->dane;

crypto/x509/x509_vfy.c:2616:5: 
2614.   static int build_chain(X509_STORE_CTX *ctx)
2615.   {
2616. >     struct dane_st *dane = (struct dane_st *)ctx->dane;
2617.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2618.       int num = sk_X509_num(ctx->chain);

crypto/x509/x509_vfy.c:2617:5: 
2615.   {
2616.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2617. >     int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2618.       int num = sk_X509_num(ctx->chain);
2619.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2618:5: 
2616.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2617.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2618. >     int num = sk_X509_num(ctx->chain);
2619.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2620.       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:2619:5: 
2617.       int (*cb) (int, X509_STORE_CTX *) = ctx->verify_cb;
2618.       int num = sk_X509_num(ctx->chain);
2619. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2620.       int ss = cert_self_signed(cert);
2621.       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:2620:5: 
2618.       int num = sk_X509_num(ctx->chain);
2619.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2620. >     int ss = cert_self_signed(cert);
2621.       STACK_OF(X509) *sktmp = NULL;
2622.       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
