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


crypto/x509/x509_lu.c:528:1: start of procedure X509_STORE_get1_certs()
526.   }
527.   
528. > STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
529.   {
530.       int i, idx, cnt;

crypto/x509/x509_lu.c:534:5: 
532.       X509 *x;
533.       X509_OBJECT *obj;
534. >     sk = sk_X509_new_null();
535.       CRYPTO_THREAD_write_lock(ctx->ctx->lock);
536.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);

include/openssl/x509.h:151:1: start of procedure sk_X509_new_null()
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:144:1: start of procedure sk_new_null()
    142.   }
    143.   
    144. > _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);

crypto/stack/stack.c:146:5: Skipping sk_new(): empty list of specs
    144.   _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
               ^
    147.   }
    148.   

crypto/stack/stack.c:147:1: return from a call to sk_new_null
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
    147. > }
    148.   
    149.   _STACK *sk_new(int (*c) (const void *, const void *))

include/openssl/x509.h:151:1: return from a call to sk_X509_new_null
  149.   typedef struct x509_cinf_st X509_CINF;
  150.   
  151. > DEFINE_STACK_OF(X509)
  152.   
  153.   /* This is used for a table of trust checking functions */

crypto/x509/x509_lu.c:535:5: 
533.       X509_OBJECT *obj;
534.       sk = sk_X509_new_null();
535. >     CRYPTO_THREAD_write_lock(ctx->ctx->lock);
536.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
537.       if (idx < 0) {

crypto/threads_pthread.c:77:1: start of procedure CRYPTO_THREAD_write_lock()
  75.   }
  76.   
  77. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
  78.   {
  79.       if (pthread_rwlock_wrlock(lock) != 0)

crypto/threads_pthread.c:79:9: Taking true branch
  77.   int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
  78.   {
  79.       if (pthread_rwlock_wrlock(lock) != 0)
                ^
  80.           return 0;
  81.   

crypto/threads_pthread.c:80:9: 
  78.   {
  79.       if (pthread_rwlock_wrlock(lock) != 0)
  80. >         return 0;
  81.   
  82.       return 1;

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

crypto/x509/x509_lu.c:536:5: Skipping x509_object_idx_cnt(): empty list of specs
534.       sk = sk_X509_new_null();
535.       CRYPTO_THREAD_write_lock(ctx->ctx->lock);
536.       idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
           ^
537.       if (idx < 0) {
538.           /*

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

crypto/x509/x509_lu.c:557:10: 
555.           }
556.       }
557. >     for (i = 0; i < cnt; i++, idx++) {
558.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
559.           x = obj->data.x509;

crypto/x509/x509_lu.c:557:17: Loop condition is true. Entering loop body
555.           }
556.       }
557.       for (i = 0; i < cnt; i++, idx++) {
                       ^
558.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
559.           x = obj->data.x509;

crypto/x509/x509_lu.c:558:9: 
556.       }
557.       for (i = 0; i < cnt; i++, idx++) {
558. >         obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
559.           x = obj->data.x509;
560.           X509_up_ref(x);

include/openssl/x509_vfy.h:102:1: start of procedure sk_X509_OBJECT_value()
  100.   
  101.   DEFINE_STACK_OF(X509_LOOKUP)
  102. > DEFINE_STACK_OF(X509_OBJECT)
  103.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  104.   

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_vfy.h:102:1: return from a call to sk_X509_OBJECT_value
  100.   
  101.   DEFINE_STACK_OF(X509_LOOKUP)
  102. > DEFINE_STACK_OF(X509_OBJECT)
  103.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  104.   

crypto/x509/x509_lu.c:559:9: 
557.       for (i = 0; i < cnt; i++, idx++) {
558.           obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
559. >         x = obj->data.x509;
560.           X509_up_ref(x);
561.           if (!sk_X509_push(sk, x)) {

STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
{
    int i, idx, cnt;
    STACK_OF(X509) *sk;
    X509 *x;
    X509_OBJECT *obj;
    sk = sk_X509_new_null();
    CRYPTO_THREAD_write_lock(ctx->ctx->lock);
    idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
    if (idx < 0) {
        X509_OBJECT xobj;
        CRYPTO_THREAD_unlock(ctx->ctx->lock);
        if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj)) {
            sk_X509_free(sk);
            return NULL;
        }
        X509_OBJECT_free_contents(&xobj);
        CRYPTO_THREAD_write_lock(ctx->ctx->lock);
        idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
        if (idx < 0) {
            CRYPTO_THREAD_unlock(ctx->ctx->lock);
            sk_X509_free(sk);
            return NULL;
        }
    }
    for (i = 0; i < cnt; i++, idx++) {
        obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
        x = obj->data.x509;
        X509_up_ref(x);
        if (!sk_X509_push(sk, x)) {
            CRYPTO_THREAD_unlock(ctx->ctx->lock);
            X509_free(x);
            sk_X509_pop_free(sk, X509_free);
            return NULL;
        }
    }
    CRYPTO_THREAD_unlock(ctx->ctx->lock);
    return sk;
}
['STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)\n{\n    int i, idx, cnt;\n    STACK_OF(X509) *sk;\n    X509 *x;\n    X509_OBJECT *obj;\n    sk = sk_X509_new_null();\n    CRYPTO_THREAD_write_lock(ctx->ctx->lock);\n    idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);\n    if (idx < 0) {\n        X509_OBJECT xobj;\n        CRYPTO_THREAD_unlock(ctx->ctx->lock);\n        if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj)) {\n            sk_X509_free(sk);\n            return NULL;\n        }\n        X509_OBJECT_free_contents(&xobj);\n        CRYPTO_THREAD_write_lock(ctx->ctx->lock);\n        idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);\n        if (idx < 0) {\n            CRYPTO_THREAD_unlock(ctx->ctx->lock);\n            sk_X509_free(sk);\n            return NULL;\n        }\n    }\n    for (i = 0; i < cnt; i++, idx++) {\n        obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);\n        x = obj->data.x509;\n        X509_up_ref(x);\n        if (!sk_X509_push(sk, x)) {\n            CRYPTO_THREAD_unlock(ctx->ctx->lock);\n            X509_free(x);\n            sk_X509_pop_free(sk, X509_free);\n            return NULL;\n        }\n    }\n    CRYPTO_THREAD_unlock(ctx->ctx->lock);\n    return sk;\n}', 'DEFINE_STACK_OF(X509)', '_STACK *sk_new_null(void)\n{\n    return sk_new((int (*)(const void *, const void *))0);\n}', 'int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)\n{\n    if (pthread_rwlock_wrlock(lock) != 0)\n        return 0;\n    return 1;\n}', 'void *sk_value(const _STACK *st, int i)\n{\n    if (!st || (i < 0) || (i >= st->num))\n        return NULL;\n    return st->data[i];\n}']