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


crypto/x509/x509_lu.c:535:1: start of procedure X509_STORE_CTX_get1_certs()
533.   }
534.   
535. > STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
536.   {
537.       int i, idx, cnt;

crypto/x509/x509_lu.c:538:5: 
536.   {
537.       int i, idx, cnt;
538. >     STACK_OF(X509) *sk = NULL;
539.       X509 *x;
540.       X509_OBJECT *obj;

crypto/x509/x509_lu.c:541:5: 
539.       X509 *x;
540.       X509_OBJECT *obj;
541. >     X509_STORE *store = ctx->store;
542.   
543.       if (store == NULL)

crypto/x509/x509_lu.c:543:9: Taking false branch
541.       X509_STORE *store = ctx->store;
542.   
543.       if (store == NULL)
               ^
544.           return NULL;
545.   

crypto/x509/x509_lu.c:546:5: 
544.           return NULL;
545.   
546. >     X509_STORE_lock(store);
547.       idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
548.       if (idx < 0) {

crypto/x509/x509_lu.c:44:1: start of procedure X509_STORE_lock()
  42.   }
  43.   
  44. > int X509_STORE_lock(X509_STORE *s)
  45.   {
  46.       return CRYPTO_THREAD_write_lock(s->lock);

crypto/x509/x509_lu.c:46:5: 
  44.   int X509_STORE_lock(X509_STORE *s)
  45.   {
  46. >     return CRYPTO_THREAD_write_lock(s->lock);
  47.   }
  48.   

crypto/threads_pthread.c:74:1: start of procedure CRYPTO_THREAD_write_lock()
    72.   }
    73.   
    74. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
    75.   {
    76.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:77:9: Taking true branch
    75.   {
    76.   # ifdef USE_RWLOCK
    77.       if (pthread_rwlock_wrlock(lock) != 0)
                  ^
    78.           return 0;
    79.   # else

crypto/threads_pthread.c:78:9: 
    76.   # ifdef USE_RWLOCK
    77.       if (pthread_rwlock_wrlock(lock) != 0)
    78. >         return 0;
    79.   # else
    80.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:85:1: return from a call to CRYPTO_THREAD_write_lock
    83.   
    84.       return 1;
    85. > }
    86.   
    87.   int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)

crypto/x509/x509_lu.c:47:1: return from a call to X509_STORE_lock
  45.   {
  46.       return CRYPTO_THREAD_write_lock(s->lock);
  47. > }
  48.   
  49.   int X509_STORE_unlock(X509_STORE *s)

crypto/x509/x509_lu.c:547:5: Skipping x509_object_idx_cnt(): empty list of specs
545.   
546.       X509_STORE_lock(store);
547.       idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
           ^
548.       if (idx < 0) {
549.           /*

crypto/x509/x509_lu.c:548:9: Taking false branch
546.       X509_STORE_lock(store);
547.       idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
548.       if (idx < 0) {
               ^
549.           /*
550.            * Nothing found in cache: do lookup to possibly add new objects to

crypto/x509/x509_lu.c:572:5: 
570.       }
571.   
572. >     sk = sk_X509_new_null();
573.       for (i = 0; i < cnt; i++, idx++) {
574.           obj = sk_X509_OBJECT_value(store->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:115:1: start of procedure OPENSSL_sk_new_null()
    113.   }
    114.   
    115. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
    116.   {
    117.       return OPENSSL_sk_new_reserve(NULL, 0);

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

crypto/stack/stack.c:118:1: return from a call to OPENSSL_sk_new_null
    116.   {
    117.       return OPENSSL_sk_new_reserve(NULL, 0);
    118. > }
    119.   
    120.   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:573:10: 
571.   
572.       sk = sk_X509_new_null();
573. >     for (i = 0; i < cnt; i++, idx++) {
574.           obj = sk_X509_OBJECT_value(store->objs, idx);
575.           x = obj->data.x509;

crypto/x509/x509_lu.c:573:17: Loop condition is true. Entering loop body
571.   
572.       sk = sk_X509_new_null();
573.       for (i = 0; i < cnt; i++, idx++) {
                       ^
574.           obj = sk_X509_OBJECT_value(store->objs, idx);
575.           x = obj->data.x509;

crypto/x509/x509_lu.c:574:9: 
572.       sk = sk_X509_new_null();
573.       for (i = 0; i < cnt; i++, idx++) {
574. >         obj = sk_X509_OBJECT_value(store->objs, idx);
575.           x = obj->data.x509;
576.           if (!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:384:1: start of procedure OPENSSL_sk_value()
    382.   }
    383.   
    384. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    385.   {
    386.       if (st == NULL || i < 0 || i >= st->num)

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

crypto/stack/stack.c:387:9: 
    385.   {
    386.       if (st == NULL || i < 0 || i >= st->num)
    387. >         return NULL;
    388.       return (void *)st->data[i];
    389.   }

crypto/stack/stack.c:389:1: return from a call to OPENSSL_sk_value
    387.           return NULL;
    388.       return (void *)st->data[i];
    389. > }
    390.   
    391.   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:575:9: 
573.       for (i = 0; i < cnt; i++, idx++) {
574.           obj = sk_X509_OBJECT_value(store->objs, idx);
575. >         x = obj->data.x509;
576.           if (!X509_up_ref(x)) {
577.               X509_STORE_unlock(store);

STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
{
    int i, idx, cnt;
    STACK_OF(X509) *sk = NULL;
    X509 *x;
    X509_OBJECT *obj;
    X509_STORE *store = ctx->store;
    if (store == NULL)
        return NULL;
    X509_STORE_lock(store);
    idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
    if (idx < 0) {
        X509_OBJECT *xobj = X509_OBJECT_new();
        X509_STORE_unlock(store);
        if (xobj == NULL)
            return NULL;
        if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) {
            X509_OBJECT_free(xobj);
            return NULL;
        }
        X509_OBJECT_free(xobj);
        X509_STORE_lock(store);
        idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
        if (idx < 0) {
            X509_STORE_unlock(store);
            return NULL;
        }
    }
    sk = sk_X509_new_null();
    for (i = 0; i < cnt; i++, idx++) {
        obj = sk_X509_OBJECT_value(store->objs, idx);
        x = obj->data.x509;
        if (!X509_up_ref(x)) {
            X509_STORE_unlock(store);
            sk_X509_pop_free(sk, X509_free);
            return NULL;
        }
        if (!sk_X509_push(sk, x)) {
            X509_STORE_unlock(store);
            X509_free(x);
            sk_X509_pop_free(sk, X509_free);
            return NULL;
        }
    }
    X509_STORE_unlock(store);
    return sk;
}
['STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)\n{\n    int i, idx, cnt;\n    STACK_OF(X509) *sk = NULL;\n    X509 *x;\n    X509_OBJECT *obj;\n    X509_STORE *store = ctx->store;\n    if (store == NULL)\n        return NULL;\n    X509_STORE_lock(store);\n    idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);\n    if (idx < 0) {\n        X509_OBJECT *xobj = X509_OBJECT_new();\n        X509_STORE_unlock(store);\n        if (xobj == NULL)\n            return NULL;\n        if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) {\n            X509_OBJECT_free(xobj);\n            return NULL;\n        }\n        X509_OBJECT_free(xobj);\n        X509_STORE_lock(store);\n        idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);\n        if (idx < 0) {\n            X509_STORE_unlock(store);\n            return NULL;\n        }\n    }\n    sk = sk_X509_new_null();\n    for (i = 0; i < cnt; i++, idx++) {\n        obj = sk_X509_OBJECT_value(store->objs, idx);\n        x = obj->data.x509;\n        if (!X509_up_ref(x)) {\n            X509_STORE_unlock(store);\n            sk_X509_pop_free(sk, X509_free);\n            return NULL;\n        }\n        if (!sk_X509_push(sk, x)) {\n            X509_STORE_unlock(store);\n            X509_free(x);\n            sk_X509_pop_free(sk, X509_free);\n            return NULL;\n        }\n    }\n    X509_STORE_unlock(store);\n    return sk;\n}', 'int X509_STORE_lock(X509_STORE *s)\n{\n    return CRYPTO_THREAD_write_lock(s->lock);\n}', 'int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)\n{\n# ifdef USE_RWLOCK\n    if (pthread_rwlock_wrlock(lock) != 0)\n        return 0;\n# else\n    if (pthread_mutex_lock(lock) != 0)\n        return 0;\n# endif\n    return 1;\n}', 'DEFINE_STACK_OF(X509)', 'OPENSSL_STACK *OPENSSL_sk_new_null(void)\n{\n    return OPENSSL_sk_new_reserve(NULL, 0);\n}', 'void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)\n{\n    if (st == NULL || i < 0 || i >= st->num)\n        return NULL;\n    return (void *)st->data[i];\n}']