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


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

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

crypto/x509/x509_lu.c:477:5: 
475.       X509_OBJECT *obj;
476.   
477. >     CRYPTO_THREAD_write_lock(ctx->ctx->lock);
478.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
479.       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:478:5: Skipping x509_object_idx_cnt(): empty list of specs
476.   
477.       CRYPTO_THREAD_write_lock(ctx->ctx->lock);
478.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
           ^
479.       if (idx < 0) {
480.           /*

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

crypto/x509/x509_lu.c:502:5: 
500.       }
501.   
502. >     sk = sk_X509_new_null();
503.       for (i = 0; i < cnt; i++, idx++) {
504.           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_zalloc(sizeof(OPENSSL_STACK));

crypto/stack/stack.c:114:5: 
    112.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
    113.   {
    114. >     return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
    115.   }
    116.   

crypto/mem.c:218:1: start of procedure CRYPTO_zalloc()
      216.   }
      217.   
      218. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      219.   {
      220.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:220:5: 
      218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      219.   {
      220. >     void *ret = CRYPTO_malloc(num, file, line);
      221.   
      222.       FAILTEST();

crypto/mem.c:189:1: start of procedure CRYPTO_malloc()
        187.   #endif
        188.   
        189. > void *CRYPTO_malloc(size_t num, const char *file, int line)
        190.   {
        191.       void *ret = NULL;

crypto/mem.c:191:5: 
        189.   void *CRYPTO_malloc(size_t num, const char *file, int line)
        190.   {
        191. >     void *ret = NULL;
        192.   
        193.       INCREMENT(malloc_count);

crypto/mem.c:194:9: Taking false branch
        192.   
        193.       INCREMENT(malloc_count);
        194.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                       ^
        195.           return malloc_impl(num, file, line);
        196.   

crypto/mem.c:197:9: Taking false branch
        195.           return malloc_impl(num, file, line);
        196.   
        197.       if (num == 0)
                       ^
        198.           return NULL;
        199.   

crypto/mem.c:201:5: 
        199.   
        200.       FAILTEST();
        201. >     allow_customize = 0;
        202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
        203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
        209.       }
        210.   #else
        211. >     (void)(file); (void)(line);
        212.       ret = malloc(num);
        213.   #endif

crypto/mem.c:211:19: 
        209.       }
        210.   #else
        211. >     (void)(file); (void)(line);
        212.       ret = malloc(num);
        213.   #endif

crypto/mem.c:212:5: 
        210.   #else
        211.       (void)(file); (void)(line);
        212. >     ret = malloc(num);
        213.   #endif
        214.   

crypto/mem.c:215:5: 
        213.   #endif
        214.   
        215. >     return ret;
        216.   }
        217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
        214.   
        215.       return ret;
        216. > }
        217.   
        218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:223:9: Taking true branch
      221.   
      222.       FAILTEST();
      223.       if (ret != NULL)
                     ^
      224.           memset(ret, 0, num);
      225.       return ret;

crypto/mem.c:224:9: 
      222.       FAILTEST();
      223.       if (ret != NULL)
      224. >         memset(ret, 0, num);
      225.       return ret;
      226.   }

crypto/mem.c:225:5: 
      223.       if (ret != NULL)
      224.           memset(ret, 0, num);
      225. >     return ret;
      226.   }
      227.   

crypto/mem.c:226:1: return from a call to CRYPTO_zalloc
      224.           memset(ret, 0, num);
      225.       return ret;
      226. > }
      227.   
      228.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/stack/stack.c:115:1: return from a call to OPENSSL_sk_new_null
    113.   {
    114.       return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
    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:503:10: 
501.   
502.       sk = sk_X509_new_null();
503. >     for (i = 0; i < cnt; i++, idx++) {
504.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
505.           x = obj->data.x509;

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

crypto/x509/x509_lu.c:504:9: 
502.       sk = sk_X509_new_null();
503.       for (i = 0; i < cnt; i++, idx++) {
504. >         obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
505.           x = obj->data.x509;
506.           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:364:1: start of procedure OPENSSL_sk_value()
    362.   }
    363.   
    364. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:366:9: Taking true branch
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    367.           return NULL;
    368.       return (void *)st->data[i];

crypto/stack/stack.c:367:9: 
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
    367. >         return NULL;
    368.       return (void *)st->data[i];
    369.   }

crypto/stack/stack.c:369:1: return from a call to OPENSSL_sk_value
    367.           return NULL;
    368.       return (void *)st->data[i];
    369. > }
    370.   
    371.   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:505:9: 
503.       for (i = 0; i < cnt; i++, idx++) {
504.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
505. >         x = obj->data.x509;
506.           X509_up_ref(x);
507.           if (!sk_X509_push(sk, x)) {
