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


crypto/x509/x509_lu.c:289:1: start of procedure X509_STORE_get_by_subject()
287.   	}
288.   
289. > int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
290.   	     X509_OBJECT *ret)
291.   	{

crypto/x509/x509_lu.c:292:2: 
290.   	     X509_OBJECT *ret)
291.   	{
292. > 	X509_STORE *ctx=vs->ctx;
293.   	X509_LOOKUP *lu;
294.   	X509_OBJECT stmp,*tmp;

crypto/x509/x509_lu.c:297:2: 
295.   	int i,j;
296.   
297. > 	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
298.   
299.   	if (tmp == NULL || type == X509_LU_CRL)

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

crypto/x509/x509_lu.c:482:2: 
  480.   {
  481.   	int idx;
  482. > 	idx = X509_OBJECT_idx_by_subject(h, type, name);
  483.   	if (idx==-1) return NULL;
  484.   	return sk_X509_OBJECT_value(h, idx);

crypto/x509/x509_lu.c:472:1: start of procedure X509_OBJECT_idx_by_subject()
    470.   
    471.   
    472. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
    473.   	     X509_NAME *name)
    474.   	{

crypto/x509/x509_lu.c:475:2: Skipping x509_object_idx_cnt(): empty list of specs
    473.   	     X509_NAME *name)
    474.   	{
    475.   	return x509_object_idx_cnt(h, type, name, NULL);
            ^
    476.   	}
    477.   

crypto/x509/x509_lu.c:476:2: return from a call to X509_OBJECT_idx_by_subject
    474.   	{
    475.   	return x509_object_idx_cnt(h, type, name, NULL);
    476.   	}
            ^
    477.   
    478.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,

crypto/x509/x509_lu.c:483:6: Taking false branch
  481.   	int idx;
  482.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  483.   	if (idx==-1) return NULL;
              ^
  484.   	return sk_X509_OBJECT_value(h, idx);
  485.   }

crypto/x509/x509_lu.c:484:9: Condition is true
  482.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  483.   	if (idx==-1) return NULL;
  484.   	return sk_X509_OBJECT_value(h, idx);
                 ^
  485.   }
  486.   

crypto/x509/x509_lu.c:484:2: 
  482.   	idx = X509_OBJECT_idx_by_subject(h, type, name);
  483.   	if (idx==-1) return NULL;
  484. > 	return sk_X509_OBJECT_value(h, idx);
  485.   }
  486.   

crypto/stack/stack.c:300:1: start of procedure sk_value()
    298.   }
    299.   
    300. > void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:302:6: Taking false branch
    300.   void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                ^
    303.   	return st->data[i];
    304.   }

crypto/stack/stack.c:302:13: Taking false branch
    300.   void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                       ^
    303.   	return st->data[i];
    304.   }

crypto/stack/stack.c:302:24: Taking false branch
    300.   void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                  ^
    303.   	return st->data[i];
    304.   }

crypto/stack/stack.c:303:2: 
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    303. > 	return st->data[i];
    304.   }
    305.   

crypto/stack/stack.c:304:1: return from a call to sk_value
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    303.   	return st->data[i];
    304. > }
    305.   
    306.   void *sk_set(_STACK *st, int i, void *value)

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

crypto/x509/x509_lu.c:299:6: Taking false branch
297.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
298.   
299.   	if (tmp == NULL || type == X509_LU_CRL)
            ^
300.   		{
301.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:299:21: Taking true branch
297.   	tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
298.   
299.   	if (tmp == NULL || type == X509_LU_CRL)
                           ^
300.   		{
301.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)

crypto/x509/x509_lu.c:301:8: 
299.   	if (tmp == NULL || type == X509_LU_CRL)
300.   		{
301. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
302.   			{
303.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:301:32: Condition is true
299.   	if (tmp == NULL || type == X509_LU_CRL)
300.   		{
301.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
                                      ^
302.   			{
303.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/x509/x509_lu.c:301:30: 
299.   	if (tmp == NULL || type == X509_LU_CRL)
300.   		{
301. > 		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
302.   			{
303.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);

crypto/stack/stack.c:294:1: start of procedure sk_num()
  292.   	}
  293.   
  294. > int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;

crypto/stack/stack.c:296:5: Taking false branch
  294.   int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;
             ^
  297.   	return st->num;
  298.   }

crypto/stack/stack.c:297:2: 
  295.   {
  296.   	if(st == NULL) return -1;
  297. > 	return st->num;
  298.   }
  299.   

crypto/stack/stack.c:298:1: return from a call to sk_num
  296.   	if(st == NULL) return -1;
  297.   	return st->num;
  298. > }
  299.   
  300.   void *sk_value(const _STACK *st, int i)

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

crypto/x509/x509_lu.c:303:7: Condition is true
301.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
302.   			{
303.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
             ^
304.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
305.   			if (j < 0)

crypto/x509/x509_lu.c:303:4: 
301.   		for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
302.   			{
303. > 			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
304.   			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
305.   			if (j < 0)

crypto/stack/stack.c:300:1: start of procedure sk_value()
  298.   }
  299.   
  300. > void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:302:6: Taking false branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:13: Taking true branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:39: 
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:304:1: return from a call to sk_value
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304. > }
  305.   
  306.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:304:4: 
302.   			{
303.   			lu=sk_X509_LOOKUP_value(ctx->get_cert_methods,i);
304. > 			j=X509_LOOKUP_by_subject(lu,type,name,&stmp);
305.   			if (j < 0)
306.   				{

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

crypto/x509/x509_lu.c:125:7: 
  123.   	     X509_OBJECT *ret)
  124.   	{
  125. > 	if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))
  126.   		return X509_LU_FAIL;
  127.   	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 || 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\ttmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);\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}', '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\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}']