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


crypto/x509/x509_lu.c:284:1: start of procedure X509_STORE_get_by_subject()
282.   	}
283.   
284. > int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
285.   	     X509_OBJECT *ret)
286.   	{

crypto/x509/x509_lu.c:287:2: 
285.   	     X509_OBJECT *ret)
286.   	{
287. > 	X509_STORE *ctx=vs->ctx;
288.   	X509_LOOKUP *lu;
289.   	X509_OBJECT stmp,*tmp;

crypto/x509/x509_lu.c:292:2: 
290.   	int i,j;
291.   
292. > 	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
293.   
294.   	if (tmp == NULL)

crypto/x509/x509_lu.c:450:1: start of procedure X509_OBJECT_retrieve_by_subject()
  448.   	}
  449.   
  450. > X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
  451.   	     X509_NAME *name)
  452.   {

crypto/x509/x509_lu.c:454:2: 
  452.   {
  453.   	int idx;
  454. > 	idx = X509_OBJECT_idx_by_subject(h, type, name);
  455.   	if (idx==-1) return NULL;
  456.   	return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:420:1: start of procedure X509_OBJECT_idx_by_subject()
    418.   	}
    419.   
    420. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
    421.   	     X509_NAME *name)
    422.   	{

crypto/x509/x509_lu.c:429:2: 
    427.   	X509_CRL_INFO crl_info_s;
    428.   
    429. > 	stmp.type=type;
    430.   	switch (type)
    431.   		{

crypto/x509/x509_lu.c:430:2: 
    428.   
    429.   	stmp.type=type;
    430. > 	switch (type)
    431.   		{
    432.   	case X509_LU_X509:

crypto/x509/x509_lu.c:432:2: Switch condition is true. Entering switch case
    430.   	switch (type)
    431.   		{
    432.   	case X509_LU_X509:
            ^
    433.   		stmp.data.x509= &x509_s;
    434.   		x509_s.cert_info= &cinf_s;

crypto/x509/x509_lu.c:433:3: 
    431.   		{
    432.   	case X509_LU_X509:
    433. > 		stmp.data.x509= &x509_s;
    434.   		x509_s.cert_info= &cinf_s;
    435.   		cinf_s.subject=name;

crypto/x509/x509_lu.c:434:3: 
    432.   	case X509_LU_X509:
    433.   		stmp.data.x509= &x509_s;
    434. > 		x509_s.cert_info= &cinf_s;
    435.   		cinf_s.subject=name;
    436.   		break;

crypto/x509/x509_lu.c:435:3: 
    433.   		stmp.data.x509= &x509_s;
    434.   		x509_s.cert_info= &cinf_s;
    435. > 		cinf_s.subject=name;
    436.   		break;
    437.   	case X509_LU_CRL:

crypto/x509/x509_lu.c:447:2: Skipping sk_find(): empty list of specs
    445.   		}
    446.   
    447.   	return sk_X509_OBJECT_find(h,&stmp);
            ^
    448.   	}
    449.   

crypto/x509/x509_lu.c:448:2: return from a call to X509_OBJECT_idx_by_subject
    446.   
    447.   	return sk_X509_OBJECT_find(h,&stmp);
    448.   	}
            ^
    449.   
    450.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,

crypto/x509/x509_lu.c:455:6: Taking false branch
  453.   	int idx;
  454.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  455.   	if (idx==-1) return NULL;
              ^
  456.   	return sk_X509_OBJECT_value(h, idx);
  457.   }

crypto/x509/x509_lu.c:456:2: 
  454.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  455.   	if (idx==-1) return NULL;
  456. > 	return sk_X509_OBJECT_value(h, idx);
  457.   }
  458.   

crypto/stack/stack.c:307:1: start of procedure sk_value()
    305.   }
    306.   
    307. > char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(st == NULL) return NULL;

crypto/stack/stack.c:309:5: Taking false branch
    307.   char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(st == NULL) return NULL;
               ^
    310.   	return st->data[i];
    311.   }

crypto/stack/stack.c:310:2: 
    308.   {
    309.   	if(st == NULL) return NULL;
    310. > 	return st->data[i];
    311.   }
    312.   

crypto/stack/stack.c:311:1: return from a call to sk_value
    309.   	if(st == NULL) return NULL;
    310.   	return st->data[i];
    311. > }
    312.   
    313.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_lu.c:457:1: return from a call to X509_OBJECT_retrieve_by_subject
  455.   	if (idx==-1) return NULL;
  456.   	return sk_X509_OBJECT_value(h, idx);
  457. > }
  458.   
  459.   X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x)

crypto/x509/x509_lu.c:294:6: Taking true branch
292.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
293.   
294.   	if (tmp == NULL)
            ^
295.   		{
296.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:296:8: 
294.   	if (tmp == NULL)
295.   		{
296. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
297.   			{
298.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:296:30: 
294.   	if (tmp == NULL)
295.   		{
296. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
297.   			{
298.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/stack/stack.c:301:1: start of procedure sk_num()
  299.   	}
  300.   
  301. > int sk_num(const STACK *st)
  302.   {
  303.   	if(st == NULL) return -1;

crypto/stack/stack.c:303:5: Taking true branch
  301.   int sk_num(const STACK *st)
  302.   {
  303.   	if(st == NULL) return -1;
             ^
  304.   	return st->num;
  305.   }

crypto/stack/stack.c:303:17: 
  301.   int sk_num(const STACK *st)
  302.   {
  303. > 	if(st == NULL) return -1;
  304.   	return st->num;
  305.   }

crypto/stack/stack.c:305:1: return from a call to sk_num
  303.   	if(st == NULL) return -1;
  304.   	return st->num;
  305. > }
  306.   
  307.   char *sk_value(const STACK *st, int i)

crypto/x509/x509_lu.c:296:30: Loop condition is true. Entering loop body
294.   	if (tmp == NULL)
295.   		{
296.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
                                    ^
297.   			{
298.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:298:4: 
296.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
297.   			{
298. > 			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
299.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
300.   			if (j < 0)

crypto/stack/stack.c:307:1: start of procedure sk_value()
  305.   }
  306.   
  307. > char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(st == NULL) return NULL;

crypto/stack/stack.c:309:5: Taking true branch
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(st == NULL) return NULL;
             ^
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:309:17: 
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309. > 	if(st == NULL) return NULL;
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:311:1: return from a call to sk_value
  309.   	if(st == NULL) return NULL;
  310.   	return st->data[i];
  311. > }
  312.   
  313.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_lu.c:299:4: 
297.   			{
298.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
299. > 			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
300.   			if (j < 0)
301.   				{

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

crypto/x509/x509_lu.c:127:7: 
  125.   	     X509_OBJECT *ret)
  126.   	{
  127. > 	if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))
  128.   		return X509_LU_FAIL;
  129.   	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;
	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
	if (tmp == NULL)
		{
		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\ttmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);\n\tif (tmp == NULL)\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}', 'X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n\t     X509_NAME *name)\n{\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}', 'int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n\t     X509_NAME *name)\n\t{\n\tX509_OBJECT stmp;\n\tX509 x509_s;\n\tX509_CINF cinf_s;\n\tX509_CRL crl_s;\n\tX509_CRL_INFO crl_info_s;\n\tstmp.type=type;\n\tswitch (type)\n\t\t{\n\tcase X509_LU_X509:\n\t\tstmp.data.x509= &x509_s;\n\t\tx509_s.cert_info= &cinf_s;\n\t\tcinf_s.subject=name;\n\t\tbreak;\n\tcase X509_LU_CRL:\n\t\tstmp.data.crl= &crl_s;\n\t\tcrl_s.crl= &crl_info_s;\n\t\tcrl_info_s.issuer=name;\n\t\tbreak;\n\tdefault:\n\t\treturn -1;\n\t\t}\n\treturn sk_X509_OBJECT_find(h,&stmp);\n\t}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(st == NULL) 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}']