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


crypto/x509/x509_lu.c:269:1: start of procedure X509_STORE_get_by_subject()
267.   	}
268.   
269. > int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
270.   	     X509_OBJECT *ret)
271.   	{

crypto/x509/x509_lu.c:272:2: 
270.   	     X509_OBJECT *ret)
271.   	{
272. > 	X509_STORE *ctx=vs->ctx;
273.   	X509_LOOKUP *lu;
274.   	X509_OBJECT stmp,*tmp;

crypto/x509/x509_lu.c:277:2: 
275.   	int i,j;
276.   
277. > 	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
278.   
279.   	if (tmp == NULL)

crypto/x509/x509_lu.c:435:1: start of procedure X509_OBJECT_retrieve_by_subject()
  433.   	}
  434.   
  435. > X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
  436.   	     X509_NAME *name)
  437.   {

crypto/x509/x509_lu.c:439:2: 
  437.   {
  438.   	int idx;
  439. > 	idx = X509_OBJECT_idx_by_subject(h, type, name);
  440.   	if (idx==-1) return NULL;
  441.   	return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:405:1: start of procedure X509_OBJECT_idx_by_subject()
    403.   	}
    404.   
    405. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
    406.   	     X509_NAME *name)
    407.   	{

crypto/x509/x509_lu.c:414:2: 
    412.   	X509_CRL_INFO crl_info_s;
    413.   
    414. > 	stmp.type=type;
    415.   	switch (type)
    416.   		{

crypto/x509/x509_lu.c:415:2: 
    413.   
    414.   	stmp.type=type;
    415. > 	switch (type)
    416.   		{
    417.   	case X509_LU_X509:

crypto/x509/x509_lu.c:417:2: Switch condition is true. Entering switch case
    415.   	switch (type)
    416.   		{
    417.   	case X509_LU_X509:
            ^
    418.   		stmp.data.x509= &x509_s;
    419.   		x509_s.cert_info= &cinf_s;

crypto/x509/x509_lu.c:418:3: 
    416.   		{
    417.   	case X509_LU_X509:
    418. > 		stmp.data.x509= &x509_s;
    419.   		x509_s.cert_info= &cinf_s;
    420.   		cinf_s.subject=name;

crypto/x509/x509_lu.c:419:3: 
    417.   	case X509_LU_X509:
    418.   		stmp.data.x509= &x509_s;
    419. > 		x509_s.cert_info= &cinf_s;
    420.   		cinf_s.subject=name;
    421.   		break;

crypto/x509/x509_lu.c:420:3: 
    418.   		stmp.data.x509= &x509_s;
    419.   		x509_s.cert_info= &cinf_s;
    420. > 		cinf_s.subject=name;
    421.   		break;
    422.   	case X509_LU_CRL:

crypto/x509/x509_lu.c:432:2: Skipping sk_find(): empty list of specs
    430.   		}
    431.   
    432.   	return sk_X509_OBJECT_find(h,&stmp);
            ^
    433.   	}
    434.   

crypto/x509/x509_lu.c:433:2: return from a call to X509_OBJECT_idx_by_subject
    431.   
    432.   	return sk_X509_OBJECT_find(h,&stmp);
    433.   	}
            ^
    434.   
    435.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,

crypto/x509/x509_lu.c:440:6: Taking false branch
  438.   	int idx;
  439.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  440.   	if (idx==-1) return NULL;
              ^
  441.   	return sk_X509_OBJECT_value(h, idx);
  442.   }

crypto/x509/x509_lu.c:441:2: 
  439.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  440.   	if (idx==-1) return NULL;
  441. > 	return sk_X509_OBJECT_value(h, idx);
  442.   }
  443.   

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

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

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

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

crypto/x509/x509_lu.c:442:1: return from a call to X509_OBJECT_retrieve_by_subject
  440.   	if (idx==-1) return NULL;
  441.   	return sk_X509_OBJECT_value(h, idx);
  442. > }
  443.   
  444.   X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x)

crypto/x509/x509_lu.c:279:6: Taking true branch
277.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
278.   
279.   	if (tmp == NULL)
            ^
280.   		{
281.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:281:8: 
279.   	if (tmp == NULL)
280.   		{
281. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
282.   			{
283.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:281:30: 
279.   	if (tmp == NULL)
280.   		{
281. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
282.   			{
283.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

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

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

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

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

crypto/x509/x509_lu.c:281:30: Loop condition is true. Entering loop body
279.   	if (tmp == NULL)
280.   		{
281.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
                                    ^
282.   			{
283.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:283:4: 
281.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
282.   			{
283. > 			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
284.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
285.   			if (j < 0)

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

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

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

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

crypto/x509/x509_lu.c:284:4: 
282.   			{
283.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
284. > 			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
285.   			if (j < 0)
286.   				{

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;
	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}']