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


crypto/x509/x509_vfy.c:2729:1: start of procedure build_chain()
2727.   }
2728.   
2729. > static int build_chain(X509_STORE_CTX *ctx)
2730.   {
2731.       struct dane_st *dane = (struct dane_st *)ctx->dane;

crypto/x509/x509_vfy.c:2731:5: 
2729.   static int build_chain(X509_STORE_CTX *ctx)
2730.   {
2731. >     struct dane_st *dane = (struct dane_st *)ctx->dane;
2732.       int num = sk_X509_num(ctx->chain);
2733.       X509 *cert = sk_X509_value(ctx->chain, num - 1);

crypto/x509/x509_vfy.c:2732:5: 
2730.   {
2731.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2732. >     int num = sk_X509_num(ctx->chain);
2733.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2734.       int ss = cert_self_signed(cert);

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

crypto/x509/x509_vfy.c:2733:5: 
2731.       struct dane_st *dane = (struct dane_st *)ctx->dane;
2732.       int num = sk_X509_num(ctx->chain);
2733. >     X509 *cert = sk_X509_value(ctx->chain, num - 1);
2734.       int ss = cert_self_signed(cert);
2735.       STACK_OF(X509) *sktmp = NULL;

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

crypto/x509/x509_vfy.c:2734:5: 
2732.       int num = sk_X509_num(ctx->chain);
2733.       X509 *cert = sk_X509_value(ctx->chain, num - 1);
2734. >     int ss = cert_self_signed(cert);
2735.       STACK_OF(X509) *sktmp = NULL;
2736.       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: 
  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/x509v3/v3_purp.c:126:1: start of procedure X509_check_purpose()
    124.    * things.
    125.    */
    126. > int X509_check_purpose(X509 *x, int id, int ca)
    127.   {
    128.       int idx;

crypto/x509v3/v3_purp.c:130:11: 
    128.       int idx;
    129.       const X509_PURPOSE *pt;
    130. >     if (!(x->ex_flags & EXFLAG_SET)) {
    131.           CRYPTO_THREAD_write_lock(x->lock);
    132.           x509v3_cache_extensions(x);
