crypto/x509/x509_lu.c:502: error: NULL_DEREFERENCE
  pointer `obj` last assigned on line 501 could be null and is dereferenced at line 502, column 13.
Showing all 25 steps of the trace


crypto/x509/x509_lu.c:467:1: start of procedure X509_STORE_CTX_get1_certs()
465.   }
466.   
467. > STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
468.   {
469.       int i, idx, cnt;

crypto/x509/x509_lu.c:470:5: 
468.   {
469.       int i, idx, cnt;
470. >     STACK_OF(X509) *sk = NULL;
471.       X509 *x;
472.       X509_OBJECT *obj;

crypto/x509/x509_lu.c:474:5: 
472.       X509_OBJECT *obj;
473.   
474. >     CRYPTO_THREAD_write_lock(ctx->ctx->lock);
475.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
476.       if (idx < 0) {

crypto/threads_pthread.c:64:1: start of procedure CRYPTO_THREAD_write_lock()
  62.   }
  63.   
  64. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
  65.   {
  66.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:67:9: Taking true branch
  65.   {
  66.   # ifdef USE_RWLOCK
  67.       if (pthread_rwlock_wrlock(lock) != 0)
                ^
  68.           return 0;
  69.   # else

crypto/threads_pthread.c:68:9: 
  66.   # ifdef USE_RWLOCK
  67.       if (pthread_rwlock_wrlock(lock) != 0)
  68. >         return 0;
  69.   # else
  70.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:75:1: return from a call to CRYPTO_THREAD_write_lock
  73.   
  74.       return 1;
  75. > }
  76.   
  77.   int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)

crypto/x509/x509_lu.c:475:5: Skipping x509_object_idx_cnt(): empty list of specs
473.   
474.       CRYPTO_THREAD_write_lock(ctx->ctx->lock);
475.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
           ^
476.       if (idx < 0) {
477.           /*

crypto/x509/x509_lu.c:476:9: Taking false branch
474.       CRYPTO_THREAD_write_lock(ctx->ctx->lock);
475.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
476.       if (idx < 0) {
               ^
477.           /*
478.            * Nothing found in cache: do lookup to possibly add new objects to

crypto/x509/x509_lu.c:499:5: 
497.       }
498.   
499. >     sk = sk_X509_new_null();
500.       for (i = 0; i < cnt; i++, idx++) {
501.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);

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

crypto/stack/stack.c:112:1: start of procedure OPENSSL_sk_new_null()
    110.   }
    111.   
    112. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
    113.   {
    114.       return OPENSSL_sk_new_reserve(NULL, 0);

crypto/stack/stack.c:114:5: Skipping OPENSSL_sk_new_reserve(): empty list of specs
    112.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
    113.   {
    114.       return OPENSSL_sk_new_reserve(NULL, 0);
               ^
    115.   }
    116.   

crypto/stack/stack.c:115:1: return from a call to OPENSSL_sk_new_null
    113.   {
    114.       return OPENSSL_sk_new_reserve(NULL, 0);
    115. > }
    116.   
    117.   OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c)

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

crypto/x509/x509_lu.c:500:10: 
498.   
499.       sk = sk_X509_new_null();
500. >     for (i = 0; i < cnt; i++, idx++) {
501.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
502.           x = obj->data.x509;

crypto/x509/x509_lu.c:500:17: Loop condition is true. Entering loop body
498.   
499.       sk = sk_X509_new_null();
500.       for (i = 0; i < cnt; i++, idx++) {
                       ^
501.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
502.           x = obj->data.x509;

crypto/x509/x509_lu.c:501:9: 
499.       sk = sk_X509_new_null();
500.       for (i = 0; i < cnt; i++, idx++) {
501. >         obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
502.           x = obj->data.x509;
503.           X509_up_ref(x);

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_value()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:380:1: start of procedure OPENSSL_sk_value()
    378.   }
    379.   
    380. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:382:9: Taking true branch
    380.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    383.           return NULL;
    384.       return (void *)st->data[i];

crypto/stack/stack.c:383:9: 
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)
    383. >         return NULL;
    384.       return (void *)st->data[i];
    385.   }

crypto/stack/stack.c:385:1: return from a call to OPENSSL_sk_value
    383.           return NULL;
    384.       return (void *)st->data[i];
    385. > }
    386.   
    387.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_value
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:502:9: 
500.       for (i = 0; i < cnt; i++, idx++) {
501.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
502. >         x = obj->data.x509;
503.           X509_up_ref(x);
504.           if (!sk_X509_push(sk, x)) {
