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


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

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

crypto/x509/x509_lu.c:305:5: 
303.       int i, j;
304.   
305. >     CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
306.       tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
307.       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:306:5: 
304.   
305.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
306. >     tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
307.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
308.   

crypto/x509/x509_lu.c:482:1: start of procedure X509_OBJECT_retrieve_by_subject()
  480.   }
  481.   
  482. > X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
  483.                                                int type, X509_NAME *name)
  484.   {

crypto/x509/x509_lu.c:486:5: 
  484.   {
  485.       int idx;
  486. >     idx = X509_OBJECT_idx_by_subject(h, type, name);
  487.       if (idx == -1)
  488.           return NULL;

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

crypto/x509/x509_lu.c:479:5: Skipping x509_object_idx_cnt(): empty list of specs
    477.                                  X509_NAME *name)
    478.   {
    479.       return x509_object_idx_cnt(h, type, name, NULL);
               ^
    480.   }
    481.   

crypto/x509/x509_lu.c:480:1: return from a call to X509_OBJECT_idx_by_subject
    478.   {
    479.       return x509_object_idx_cnt(h, type, name, NULL);
    480. > }
    481.   
    482.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,

crypto/x509/x509_lu.c:487:9: Taking false branch
  485.       int idx;
  486.       idx = X509_OBJECT_idx_by_subject(h, type, name);
  487.       if (idx == -1)
                 ^
  488.           return NULL;
  489.       return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:489:12: Condition is true
  487.       if (idx == -1)
  488.           return NULL;
  489.       return sk_X509_OBJECT_value(h, idx);
                    ^
  490.   }
  491.   

crypto/x509/x509_lu.c:489:5: 
  487.       if (idx == -1)
  488.           return NULL;
  489. >     return sk_X509_OBJECT_value(h, idx);
  490.   }
  491.   

crypto/stack/stack.c:328:1: start of procedure sk_value()
    326.   }
    327.   
    328. > void *sk_value(const _STACK *st, int i)
    329.   {
    330.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:330:10: Taking false branch
    328.   void *sk_value(const _STACK *st, int i)
    329.   {
    330.       if (!st || (i < 0) || (i >= st->num))
                    ^
    331.           return NULL;
    332.       return st->data[i];

crypto/stack/stack.c:330:17: Taking false branch
    328.   void *sk_value(const _STACK *st, int i)
    329.   {
    330.       if (!st || (i < 0) || (i >= st->num))
                           ^
    331.           return NULL;
    332.       return st->data[i];

crypto/stack/stack.c:330:28: Taking false branch
    328.   void *sk_value(const _STACK *st, int i)
    329.   {
    330.       if (!st || (i < 0) || (i >= st->num))
                                      ^
    331.           return NULL;
    332.       return st->data[i];

crypto/stack/stack.c:332:5: 
    330.       if (!st || (i < 0) || (i >= st->num))
    331.           return NULL;
    332. >     return st->data[i];
    333.   }
    334.   

crypto/stack/stack.c:333:1: return from a call to sk_value
    331.           return NULL;
    332.       return st->data[i];
    333. > }
    334.   
    335.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:490:1: return from a call to X509_OBJECT_retrieve_by_subject
  488.           return NULL;
  489.       return sk_X509_OBJECT_value(h, idx);
  490. > }
  491.   
  492.   STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)

crypto/x509/x509_lu.c:307:5: 
305.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
306.       tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
307. >     CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
308.   
309.       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:309:9: Taking false branch
307.       CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
308.   
309.       if (tmp == NULL || type == X509_LU_CRL) {
               ^
310.           for (i = vs->current_method;
311.                i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {

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

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

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

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

crypto/stack/stack.c:321:1: start of procedure sk_num()
  319.   }
  320.   
  321. > int sk_num(const _STACK *st)
  322.   {
  323.       if (st == NULL)

crypto/stack/stack.c:323:9: Taking false branch
  321.   int sk_num(const _STACK *st)
  322.   {
  323.       if (st == NULL)
                 ^
  324.           return -1;
  325.       return st->num;

crypto/stack/stack.c:325:5: 
  323.       if (st == NULL)
  324.           return -1;
  325. >     return st->num;
  326.   }
  327.   

crypto/stack/stack.c:326:1: return from a call to sk_num
  324.           return -1;
  325.       return st->num;
  326. > }
  327.   
  328.   void *sk_value(const _STACK *st, int i)

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

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

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

crypto/stack/stack.c:328:1: start of procedure sk_value()
  326.   }
  327.   
  328. > void *sk_value(const _STACK *st, int i)
  329.   {
  330.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:330:10: Taking false branch
  328.   void *sk_value(const _STACK *st, int i)
  329.   {
  330.       if (!st || (i < 0) || (i >= st->num))
                  ^
  331.           return NULL;
  332.       return st->data[i];

crypto/stack/stack.c:330:17: Taking true branch
  328.   void *sk_value(const _STACK *st, int i)
  329.   {
  330.       if (!st || (i < 0) || (i >= st->num))
                         ^
  331.           return NULL;
  332.       return st->data[i];

crypto/stack/stack.c:331:9: 
  329.   {
  330.       if (!st || (i < 0) || (i >= st->num))
  331. >         return NULL;
  332.       return st->data[i];
  333.   }

crypto/stack/stack.c:333:1: return from a call to sk_value
  331.           return NULL;
  332.       return st->data[i];
  333. > }
  334.   
  335.   void *sk_set(_STACK *st, int i, void *value)

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