crypto/x509/x509_lu.c:312: error: NULL_DEREFERENCE
  pointer `lu` last assigned on line 311 could be null and is dereferenced by call to `X509_LOOKUP_by_subject()` at line 312, column 17.
Showing all 52 steps of the trace


crypto/x509/x509_lu.c:296:1: start of procedure X509_STORE_get_by_subject()
294.   }
295.   
296. > int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
297.                                 X509_OBJECT *ret)
298.   {

crypto/x509/x509_lu.c:299:5: 
297.                                 X509_OBJECT *ret)
298.   {
299. >     X509_STORE *ctx = vs->ctx;
300.       X509_LOOKUP *lu;
301.       X509_OBJECT stmp, *tmp;

crypto/x509/x509_lu.c:304:5: 
302.       int i, j;
303.   
304. >     CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
305.       tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
306.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);

crypto/lock.c:417:1: start of procedure CRYPTO_lock()
  415.   }
  416.   
  417. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  418.   {
  419.   #ifdef LOCK_DEBUG

crypto/lock.c:444:9: Taking false branch
  442.       }
  443.   #endif
  444.       if (type < 0) {
                 ^
  445.           if (dynlock_lock_callback != NULL) {
  446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:455:16: Taking true branch
  453.               CRYPTO_destroy_dynlockid(type);
  454.           }
  455.       } else if (locking_callback != NULL)
                        ^
  456.           locking_callback(mode, type, file, line);
  457.   }

crypto/lock.c:456:9: Skipping __function_pointer__(): unresolved function pointer
  454.           }
  455.       } else if (locking_callback != NULL)
  456.           locking_callback(mode, type, file, line);
                 ^
  457.   }
  458.   

crypto/lock.c:444:5: 
  442.       }
  443.   #endif
  444. >     if (type < 0) {
  445.           if (dynlock_lock_callback != NULL) {
  446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:457:1: return from a call to CRYPTO_lock
  455.       } else if (locking_callback != NULL)
  456.           locking_callback(mode, type, file, line);
  457. > }
  458.   
  459.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:305:5: 
303.   
304.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
305. >     tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
306.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
307.   

crypto/x509/x509_lu.c:475:1: start of procedure X509_OBJECT_retrieve_by_subject()
  473.   }
  474.   
  475. > X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
  476.                                                int type, X509_NAME *name)
  477.   {

crypto/x509/x509_lu.c:479:5: 
  477.   {
  478.       int idx;
  479. >     idx = X509_OBJECT_idx_by_subject(h, type, name);
  480.       if (idx == -1)
  481.           return NULL;

crypto/x509/x509_lu.c:469:1: start of procedure X509_OBJECT_idx_by_subject()
    467.   }
    468.   
    469. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
    470.                                  X509_NAME *name)
    471.   {

crypto/x509/x509_lu.c:472:5: Skipping x509_object_idx_cnt(): empty list of specs
    470.                                  X509_NAME *name)
    471.   {
    472.       return x509_object_idx_cnt(h, type, name, NULL);
               ^
    473.   }
    474.   

crypto/x509/x509_lu.c:473:1: return from a call to X509_OBJECT_idx_by_subject
    471.   {
    472.       return x509_object_idx_cnt(h, type, name, NULL);
    473. > }
    474.   
    475.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,

crypto/x509/x509_lu.c:480:9: Taking false branch
  478.       int idx;
  479.       idx = X509_OBJECT_idx_by_subject(h, type, name);
  480.       if (idx == -1)
                 ^
  481.           return NULL;
  482.       return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:482:12: Condition is true
  480.       if (idx == -1)
  481.           return NULL;
  482.       return sk_X509_OBJECT_value(h, idx);
                    ^
  483.   }
  484.   

crypto/x509/x509_lu.c:482:5: 
  480.       if (idx == -1)
  481.           return NULL;
  482. >     return sk_X509_OBJECT_value(h, idx);
  483.   }
  484.   

crypto/stack/stack.c:347:1: start of procedure sk_value()
    345.   }
    346.   
    347. > void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:349:10: Taking false branch
    347.   void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))
                    ^
    350.           return NULL;
    351.       return st->data[i];

crypto/stack/stack.c:349:17: Taking false branch
    347.   void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))
                           ^
    350.           return NULL;
    351.       return st->data[i];

crypto/stack/stack.c:349:28: Taking false branch
    347.   void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))
                                      ^
    350.           return NULL;
    351.       return st->data[i];

crypto/stack/stack.c:351:5: 
    349.       if (!st || (i < 0) || (i >= st->num))
    350.           return NULL;
    351. >     return st->data[i];
    352.   }
    353.   

crypto/stack/stack.c:352:1: return from a call to sk_value
    350.           return NULL;
    351.       return st->data[i];
    352. > }
    353.   
    354.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:483:1: return from a call to X509_OBJECT_retrieve_by_subject
  481.           return NULL;
  482.       return sk_X509_OBJECT_value(h, idx);
  483. > }
  484.   
  485.   STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)

crypto/x509/x509_lu.c:306:5: 
304.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
305.       tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
306. >     CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
307.   
308.       if (tmp == NULL || type == X509_LU_CRL) {

crypto/lock.c:417:1: start of procedure CRYPTO_lock()
  415.   }
  416.   
  417. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  418.   {
  419.   #ifdef LOCK_DEBUG

crypto/lock.c:444:9: Taking false branch
  442.       }
  443.   #endif
  444.       if (type < 0) {
                 ^
  445.           if (dynlock_lock_callback != NULL) {
  446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:455:16: Taking true branch
  453.               CRYPTO_destroy_dynlockid(type);
  454.           }
  455.       } else if (locking_callback != NULL)
                        ^
  456.           locking_callback(mode, type, file, line);
  457.   }

crypto/lock.c:456:9: Skipping __function_pointer__(): unresolved function pointer
  454.           }
  455.       } else if (locking_callback != NULL)
  456.           locking_callback(mode, type, file, line);
                 ^
  457.   }
  458.   

crypto/lock.c:444:5: 
  442.       }
  443.   #endif
  444. >     if (type < 0) {
  445.           if (dynlock_lock_callback != NULL) {
  446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:457:1: return from a call to CRYPTO_lock
  455.       } else if (locking_callback != NULL)
  456.           locking_callback(mode, type, file, line);
  457. > }
  458.   
  459.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:308:9: Taking false branch
306.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
307.   
308.       if (tmp == NULL || type == X509_LU_CRL) {
               ^
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {

crypto/x509/x509_lu.c:308:24: Taking true branch
306.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
307.   
308.       if (tmp == NULL || type == X509_LU_CRL) {
                              ^
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {

crypto/x509/x509_lu.c:309:14: 
307.   
308.       if (tmp == NULL || type == X509_LU_CRL) {
309. >         for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);

crypto/x509/x509_lu.c:310:18: Condition is true
308.       if (tmp == NULL || type == X509_LU_CRL) {
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
                        ^
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
312.               j = X509_LOOKUP_by_subject(lu, type, name, &stmp);

crypto/x509/x509_lu.c:310:14: 
308.       if (tmp == NULL || type == X509_LU_CRL) {
309.           for (i = vs->current_method;
310. >              i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
312.               j = X509_LOOKUP_by_subject(lu, type, name, &stmp);

crypto/stack/stack.c:340:1: start of procedure sk_num()
  338.   }
  339.   
  340. > int sk_num(const _STACK *st)
  341.   {
  342.       if (st == NULL)

crypto/stack/stack.c:342:9: Taking false branch
  340.   int sk_num(const _STACK *st)
  341.   {
  342.       if (st == NULL)
                 ^
  343.           return -1;
  344.       return st->num;

crypto/stack/stack.c:344:5: 
  342.       if (st == NULL)
  343.           return -1;
  344. >     return st->num;
  345.   }
  346.   

crypto/stack/stack.c:345:1: return from a call to sk_num
  343.           return -1;
  344.       return st->num;
  345. > }
  346.   
  347.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_lu.c:310:14: Loop condition is true. Entering loop body
308.       if (tmp == NULL || type == X509_LU_CRL) {
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
                    ^
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
312.               j = X509_LOOKUP_by_subject(lu, type, name, &stmp);

crypto/x509/x509_lu.c:311:18: Condition is true
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
                        ^
312.               j = X509_LOOKUP_by_subject(lu, type, name, &stmp);
313.               if (j < 0) {

crypto/x509/x509_lu.c:311:13: 
309.           for (i = vs->current_method;
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
311. >             lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
312.               j = X509_LOOKUP_by_subject(lu, type, name, &stmp);
313.               if (j < 0) {

crypto/stack/stack.c:347:1: start of procedure sk_value()
  345.   }
  346.   
  347. > void *sk_value(const _STACK *st, int i)
  348.   {
  349.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:349:10: Taking false branch
  347.   void *sk_value(const _STACK *st, int i)
  348.   {
  349.       if (!st || (i < 0) || (i >= st->num))
                  ^
  350.           return NULL;
  351.       return st->data[i];

crypto/stack/stack.c:349:17: Taking true branch
  347.   void *sk_value(const _STACK *st, int i)
  348.   {
  349.       if (!st || (i < 0) || (i >= st->num))
                         ^
  350.           return NULL;
  351.       return st->data[i];

crypto/stack/stack.c:350:9: 
  348.   {
  349.       if (!st || (i < 0) || (i >= st->num))
  350. >         return NULL;
  351.       return st->data[i];
  352.   }

crypto/stack/stack.c:352:1: return from a call to sk_value
  350.           return NULL;
  351.       return st->data[i];
  352. > }
  353.   
  354.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:312:13: 
310.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
311.               lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
312. >             j = X509_LOOKUP_by_subject(lu, type, name, &stmp);
313.               if (j < 0) {
314.                   vs->current_method = j;

crypto/x509/x509_lu.c:126:1: start of procedure X509_LOOKUP_by_subject()
  124.   }
  125.   
  126. > int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
  127.                              X509_OBJECT *ret)
  128.   {

crypto/x509/x509_lu.c:129:10: 
  127.                              X509_OBJECT *ret)
  128.   {
  129. >     if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))
  130.           return X509_LU_FAIL;
  131.       if (ctx->skip)
