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


crypto/x509/x509_lu.c:303:1: start of procedure X509_STORE_get_by_subject()
301.   	}
302.   
303. > int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
304.   	     X509_OBJECT *ret)
305.   	{

crypto/x509/x509_lu.c:306:2: 
304.   	     X509_OBJECT *ret)
305.   	{
306. > 	X509_STORE *ctx=vs->ctx;
307.   	X509_LOOKUP *lu;
308.   	X509_OBJECT stmp,*tmp;

crypto/x509/x509_lu.c:311:2: 
309.   	int i,j;
310.   
311. > 	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
312.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
313.   	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);

crypto/lock.c:423:1: start of procedure CRYPTO_lock()
  421.   	}
  422.   
  423. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  424.   	{
  425.   #ifdef LOCK_DEBUG

crypto/lock.c:450:6: Taking false branch
  448.   		}
  449.   #endif
  450.   	if (type < 0)
              ^
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:465:7: Taking true branch
  463.   		}
  464.   	else
  465.   		if (locking_callback != NULL)
               ^
  466.   			locking_callback(mode,type,file,line);
  467.   	}

crypto/lock.c:466:4: Skipping __function_pointer__(): unresolved function pointer
  464.   	else
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
            ^
  467.   	}
  468.   

crypto/lock.c:450:2: 
  448.   		}
  449.   #endif
  450. > 	if (type < 0)
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:467:2: return from a call to CRYPTO_lock
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
  467.   	}
          ^
  468.   
  469.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:312:2: 
310.   
311.   	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
312. > 	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
313.   	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
314.   

crypto/x509/x509_lu.c:493:1: start of procedure X509_OBJECT_retrieve_by_subject()
  491.   	}
  492.   
  493. > X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
  494.   	     X509_NAME *name)
  495.   	{

crypto/x509/x509_lu.c:497:2: 
  495.   	{
  496.   	int idx;
  497. > 	idx = X509_OBJECT_idx_by_subject(h, type, name);
  498.   	if (idx==-1) return NULL;
  499.   	return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:487:1: start of procedure X509_OBJECT_idx_by_subject()
    485.   
    486.   
    487. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
    488.   	     X509_NAME *name)
    489.   	{

crypto/x509/x509_lu.c:490:2: Skipping x509_object_idx_cnt(): empty list of specs
    488.   	     X509_NAME *name)
    489.   	{
    490.   	return x509_object_idx_cnt(h, type, name, NULL);
            ^
    491.   	}
    492.   

crypto/x509/x509_lu.c:491:2: return from a call to X509_OBJECT_idx_by_subject
    489.   	{
    490.   	return x509_object_idx_cnt(h, type, name, NULL);
    491.   	}
            ^
    492.   
    493.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,

crypto/x509/x509_lu.c:498:6: Taking false branch
  496.   	int idx;
  497.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  498.   	if (idx==-1) return NULL;
              ^
  499.   	return sk_X509_OBJECT_value(h, idx);
  500.   	}

crypto/x509/x509_lu.c:499:9: Condition is true
  497.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  498.   	if (idx==-1) return NULL;
  499.   	return sk_X509_OBJECT_value(h, idx);
                 ^
  500.   	}
  501.   

crypto/x509/x509_lu.c:499:2: 
  497.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  498.   	if (idx==-1) return NULL;
  499. > 	return sk_X509_OBJECT_value(h, idx);
  500.   	}
  501.   

crypto/stack/stack.c:338:1: start of procedure sk_value()
    336.   }
    337.   
    338. > void *sk_value(const _STACK *st, int i)
    339.   {
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:340:6: Taking false branch
    338.   void *sk_value(const _STACK *st, int i)
    339.   {
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                ^
    341.   	return st->data[i];
    342.   }

crypto/stack/stack.c:340:13: Taking false branch
    338.   void *sk_value(const _STACK *st, int i)
    339.   {
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                       ^
    341.   	return st->data[i];
    342.   }

crypto/stack/stack.c:340:24: Taking false branch
    338.   void *sk_value(const _STACK *st, int i)
    339.   {
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                  ^
    341.   	return st->data[i];
    342.   }

crypto/stack/stack.c:341:2: 
    339.   {
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    341. > 	return st->data[i];
    342.   }
    343.   

crypto/stack/stack.c:342:1: return from a call to sk_value
    340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    341.   	return st->data[i];
    342. > }
    343.   
    344.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:500:2: return from a call to X509_OBJECT_retrieve_by_subject
  498.   	if (idx==-1) return NULL;
  499.   	return sk_X509_OBJECT_value(h, idx);
  500.   	}
          ^
  501.   
  502.   STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)

crypto/x509/x509_lu.c:313:2: 
311.   	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
312.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
313. > 	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
314.   
315.   	if (tmp == NULL || type == X509_LU_CRL)

crypto/lock.c:423:1: start of procedure CRYPTO_lock()
  421.   	}
  422.   
  423. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  424.   	{
  425.   #ifdef LOCK_DEBUG

crypto/lock.c:450:6: Taking false branch
  448.   		}
  449.   #endif
  450.   	if (type < 0)
              ^
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:465:7: Taking true branch
  463.   		}
  464.   	else
  465.   		if (locking_callback != NULL)
               ^
  466.   			locking_callback(mode,type,file,line);
  467.   	}

crypto/lock.c:466:4: Skipping __function_pointer__(): unresolved function pointer
  464.   	else
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
            ^
  467.   	}
  468.   

crypto/lock.c:450:2: 
  448.   		}
  449.   #endif
  450. > 	if (type < 0)
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:467:2: return from a call to CRYPTO_lock
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
  467.   	}
          ^
  468.   
  469.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:315:6: Taking false branch
313.   	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
314.   
315.   	if (tmp == NULL || type == X509_LU_CRL)
            ^
316.   		{
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:315:21: Taking true branch
313.   	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
314.   
315.   	if (tmp == NULL || type == X509_LU_CRL)
                           ^
316.   		{
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:317:8: 
315.   	if (tmp == NULL || type == X509_LU_CRL)
316.   		{
317. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:317:32: Condition is true
315.   	if (tmp == NULL || type == X509_LU_CRL)
316.   		{
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
                                      ^
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:317:30: 
315.   	if (tmp == NULL || type == X509_LU_CRL)
316.   		{
317. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/stack/stack.c:332:1: start of procedure sk_num()
  330.   	}
  331.   
  332. > int sk_num(const _STACK *st)
  333.   {
  334.   	if(st == NULL) return -1;

crypto/stack/stack.c:334:5: Taking false branch
  332.   int sk_num(const _STACK *st)
  333.   {
  334.   	if(st == NULL) return -1;
             ^
  335.   	return st->num;
  336.   }

crypto/stack/stack.c:335:2: 
  333.   {
  334.   	if(st == NULL) return -1;
  335. > 	return st->num;
  336.   }
  337.   

crypto/stack/stack.c:336:1: return from a call to sk_num
  334.   	if(st == NULL) return -1;
  335.   	return st->num;
  336. > }
  337.   
  338.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_lu.c:317:30: Loop condition is true. Entering loop body
315.   	if (tmp == NULL || type == X509_LU_CRL)
316.   		{
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
                                    ^
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:319:7: Condition is true
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
             ^
320.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
321.   			if (j < 0)

crypto/x509/x509_lu.c:319:4: 
317.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
318.   			{
319. > 			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
320.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
321.   			if (j < 0)

crypto/stack/stack.c:338:1: start of procedure sk_value()
  336.   }
  337.   
  338. > void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:340:6: Taking false branch
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:340:13: Taking true branch
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:340:39: 
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:342:1: return from a call to sk_value
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  341.   	return st->data[i];
  342. > }
  343.   
  344.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:320:4: 
318.   			{
319.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
320. > 			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
321.   			if (j < 0)
322.   				{

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

crypto/x509/x509_lu.c:126:7: 
  124.   	     X509_OBJECT *ret)
  125.   	{
  126. > 	if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))
  127.   		return X509_LU_FAIL;
  128.   	if (ctx->skip) return 0;

int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
	     X509_OBJECT *ret)
	{
	X509_STORE *ctx=vs->ctx;
	X509_LOOKUP *lu;
	X509_OBJECT stmp,*tmp;
	int i,j;
	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
	if (tmp == NULL || type == X509_LU_CRL)
		{
		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
			{
			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
			if (j < 0)
				{
				vs->current_method=j;
				return j;
				}
			else if (j)
				{
				tmp= &stmp;
				break;
				}
			}
		vs->current_method=0;
		if (tmp == NULL)
			return 0;
		}
	ret->type=tmp->type;
	ret->data.ptr=tmp->data.ptr;
	X509_OBJECT_up_ref_count(ret);
	return 1;
	}
['int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,\n\t     X509_OBJECT *ret)\n\t{\n\tX509_STORE *ctx=vs->ctx;\n\tX509_LOOKUP *lu;\n\tX509_OBJECT stmp,*tmp;\n\tint i,j;\n\tCRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);\n\ttmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);\n\tCRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n\tif (tmp == NULL || type == X509_LU_CRL)\n\t\t{\n\t\tfor (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)\n\t\t\t{\n\t\t\tlu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);\n\t\t\tj=X509_LOOKUP_by_subject(lu,type,name,&stmp);\n\t\t\tif (j < 0)\n\t\t\t\t{\n\t\t\t\tvs->current_method=j;\n\t\t\t\treturn j;\n\t\t\t\t}\n\t\t\telse if (j)\n\t\t\t\t{\n\t\t\t\ttmp= &stmp;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tvs->current_method=0;\n\t\tif (tmp == NULL)\n\t\t\treturn 0;\n\t\t}\n\tret->type=tmp->type;\n\tret->data.ptr=tmp->data.ptr;\n\tX509_OBJECT_up_ref_count(ret);\n\treturn 1;\n\t}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tCRYPTO_THREADID id;\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tCRYPTO_THREADID_current(&id);\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_THREADID_hash(&id), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (type < 0)\n\t\t{\n\t\tif (dynlock_lock_callback != NULL)\n\t\t\t{\n\t\t\tstruct CRYPTO_dynlock_value *pointer\n\t\t\t\t= CRYPTO_get_dynlock_value(type);\n\t\t\tOPENSSL_assert(pointer != NULL);\n\t\t\tdynlock_lock_callback(mode, pointer, file, line);\n\t\t\tCRYPTO_destroy_dynlockid(type);\n\t\t\t}\n\t\t}\n\telse\n\t\tif (locking_callback != NULL)\n\t\t\tlocking_callback(mode,type,file,line);\n\t}', 'X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n\t     X509_NAME *name)\n\t{\n\tint idx;\n\tidx = X509_OBJECT_idx_by_subject(h, type, name);\n\tif (idx==-1) return NULL;\n\treturn sk_X509_OBJECT_value(h, idx);\n\t}', 'int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n\t     X509_NAME *name)\n\t{\n\treturn x509_object_idx_cnt(h, type, name, NULL);\n\t}', 'void *sk_value(const _STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}', 'int sk_num(const _STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,\n\t     X509_OBJECT *ret)\n\t{\n\tif ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))\n\t\treturn X509_LU_FAIL;\n\tif (ctx->skip) return 0;\n\treturn ctx->method->get_by_subject(ctx,type,name,ret);\n\t}']