crypto/x509/x509_req.c:201: error: NULL_DEREFERENCE
  pointer `attr` last assigned on line 200 could be null and is dereferenced at line 201, column 6.
Showing all 53 steps of the trace


crypto/x509/x509_req.c:186:1: start of procedure X509_REQ_get_extensions()
184.   }
185.   
186. > STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
187.   	{
188.   	X509_ATTRIBUTE *attr;

crypto/x509/x509_req.c:189:2: 
187.   	{
188.   	X509_ATTRIBUTE *attr;
189. > 	ASN1_TYPE *ext = NULL;
190.   	int idx, *pnid;
191.   	const unsigned char *p;

crypto/x509/x509_req.c:193:7: Taking false branch
191.   	const unsigned char *p;
192.   
193.   	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
             ^
194.   		return(NULL);
195.   	for (pnid = ext_nids; *pnid != NID_undef; pnid++)

crypto/x509/x509_req.c:193:24: Taking false branch
191.   	const unsigned char *p;
192.   
193.   	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
                              ^
194.   		return(NULL);
195.   	for (pnid = ext_nids; *pnid != NID_undef; pnid++)

crypto/x509/x509_req.c:193:51: Taking false branch
191.   	const unsigned char *p;
192.   
193.   	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
                                                         ^
194.   		return(NULL);
195.   	for (pnid = ext_nids; *pnid != NID_undef; pnid++)

crypto/x509/x509_req.c:195:7: 
193.   	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
194.   		return(NULL);
195. > 	for (pnid = ext_nids; *pnid != NID_undef; pnid++)
196.   		{
197.   		idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);

crypto/x509/x509_req.c:195:24: Loop condition is true. Entering loop body
193.   	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
194.   		return(NULL);
195.   	for (pnid = ext_nids; *pnid != NID_undef; pnid++)
                              ^
196.   		{
197.   		idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);

crypto/x509/x509_req.c:197:3: 
195.   	for (pnid = ext_nids; *pnid != NID_undef; pnid++)
196.   		{
197. > 		idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);
198.   		if (idx == -1)
199.   			continue;

crypto/x509/x509_req.c:263:1: start of procedure X509_REQ_get_attr_by_NID()
  261.   }
  262.   
  263. > int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
  264.   			  int lastpos)
  265.   {

crypto/x509/x509_req.c:266:2: 
  264.   			  int lastpos)
  265.   {
  266. > 	return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos);
  267.   }
  268.   

crypto/x509/x509_att.c:74:1: start of procedure X509at_get_attr_by_NID()
    72.   }
    73.   
    74. > int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
    75.   			  int lastpos)
    76.   {

crypto/x509/x509_att.c:79:2: 
    77.   	ASN1_OBJECT *obj;
    78.   
    79. > 	obj=OBJ_nid2obj(nid);
    80.   	if (obj == NULL) return(-2);
    81.   	return(X509at_get_attr_by_OBJ(x,obj,lastpos));

crypto/objects/obj_dat.c:293:1: start of procedure OBJ_nid2obj()
      291.   	}
      292.   
      293. > ASN1_OBJECT *OBJ_nid2obj(int n)
      294.   	{
      295.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:298:7: Taking true branch
      296.   	ASN1_OBJECT ob;
      297.   
      298.   	if ((n >= 0) && (n < NUM_NID))
                   ^
      299.   		{
      300.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:298:19: Taking true branch
      296.   	ASN1_OBJECT ob;
      297.   
      298.   	if ((n >= 0) && (n < NUM_NID))
                               ^
      299.   		{
      300.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:300:8: Taking true branch
      298.   	if ((n >= 0) && (n < NUM_NID))
      299.   		{
      300.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                    ^
      301.   			{
      302.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:300:28: Taking true branch
      298.   	if ((n >= 0) && (n < NUM_NID))
      299.   		{
      300.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                                        ^
      301.   			{
      302.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:302:4: 
      300.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
      301.   			{
      302. > 			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
      303.   			return(NULL);
      304.   			}

crypto/err/err.c:680:1: start of procedure ERR_put_error()
        678.   /********************************************************/
        679.   
        680. > void ERR_put_error(int lib, int func, int reason, const char *file,
        681.   	     int line)
        682.   	{

crypto/err/err.c:704:2: Skipping ERR_get_state(): empty list of specs
        702.   	}
        703.   #endif
        704.   	es=ERR_get_state();
                ^
        705.   
        706.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:706:2: 
        704.   	es=ERR_get_state();
        705.   
        706. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
        707.   	if (es->top == es->bottom)
        708.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:707:6: Taking false branch
        705.   
        706.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
        707.   	if (es->top == es->bottom)
                    ^
        708.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        709.   	es->err_flags[es->top]=0;

crypto/err/err.c:709:2: 
        707.   	if (es->top == es->bottom)
        708.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        709. > 	es->err_flags[es->top]=0;
        710.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        711.   	es->err_file[es->top]=file;

crypto/err/err.c:710:2: 
        708.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        709.   	es->err_flags[es->top]=0;
        710. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        711.   	es->err_file[es->top]=file;
        712.   	es->err_line[es->top]=line;

crypto/err/err.c:711:2: 
        709.   	es->err_flags[es->top]=0;
        710.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        711. > 	es->err_file[es->top]=file;
        712.   	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);

crypto/err/err.c:712:2: 
        710.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        711.   	es->err_file[es->top]=file;
        712. > 	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);
        714.   	}

crypto/err/err.c:713:2: Taking true branch
        711.   	es->err_file[es->top]=file;
        712.   	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);
                ^
        714.   	}
        715.   

crypto/err/err.c:713:2: Taking false branch
        711.   	es->err_file[es->top]=file;
        712.   	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);
                ^
        714.   	}
        715.   

crypto/err/err.c:713:2: Loop condition is false. Leaving loop
        711.   	es->err_file[es->top]=file;
        712.   	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);
                ^
        714.   	}
        715.   

crypto/err/err.c:714:2: return from a call to ERR_put_error
        712.   	es->err_line[es->top]=line;
        713.   	err_clear_data(es,es->top);
        714.   	}
                ^
        715.   
        716.   void ERR_clear_error(void)

crypto/objects/obj_dat.c:303:4: 
      301.   			{
      302.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
      303. > 			return(NULL);
      304.   			}
      305.   		return((ASN1_OBJECT *)&(nid_objs[n]));

crypto/objects/obj_dat.c:323:2: return from a call to OBJ_nid2obj
      321.   			}
      322.   		}
      323.   	}
              ^
      324.   
      325.   const char *OBJ_nid2sn(int n)

crypto/x509/x509_att.c:80:6: Taking true branch
    78.   
    79.   	obj=OBJ_nid2obj(nid);
    80.   	if (obj == NULL) return(-2);
               ^
    81.   	return(X509at_get_attr_by_OBJ(x,obj,lastpos));
    82.   }

crypto/x509/x509_att.c:80:19: 
    78.   
    79.   	obj=OBJ_nid2obj(nid);
    80. > 	if (obj == NULL) return(-2);
    81.   	return(X509at_get_attr_by_OBJ(x,obj,lastpos));
    82.   }

crypto/x509/x509_att.c:82:1: return from a call to X509at_get_attr_by_NID
    80.   	if (obj == NULL) return(-2);
    81.   	return(X509at_get_attr_by_OBJ(x,obj,lastpos));
    82. > }
    83.   
    84.   int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,

crypto/x509/x509_req.c:267:1: return from a call to X509_REQ_get_attr_by_NID
  265.   {
  266.   	return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos);
  267. > }
  268.   
  269.   int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,

crypto/x509/x509_req.c:198:7: Taking false branch
196.   		{
197.   		idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);
198.   		if (idx == -1)
             ^
199.   			continue;
200.   		attr = X509_REQ_get_attr(req, idx);

crypto/x509/x509_req.c:200:3: 
198.   		if (idx == -1)
199.   			continue;
200. > 		attr = X509_REQ_get_attr(req, idx);
201.   		if(attr->single) ext = attr->value.single;
202.   		else if(sk_ASN1_TYPE_num(attr->value.set))

crypto/x509/x509_req.c:275:1: start of procedure X509_REQ_get_attr()
  273.   }
  274.   
  275. > X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc)
  276.   {
  277.   	return X509at_get_attr(req->req_info->attributes, loc);

crypto/x509/x509_req.c:277:2: 
  275.   X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc)
  276.   {
  277. > 	return X509at_get_attr(req->req_info->attributes, loc);
  278.   }
  279.   

crypto/x509/x509_att.c:104:1: start of procedure X509at_get_attr()
    102.   }
    103.   
    104. > X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
    105.   {
    106.   	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)

crypto/x509/x509_att.c:106:6: Taking false branch
    104.   X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
    105.   {
    106.   	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
                ^
    107.   		return NULL;
    108.   	else

crypto/x509/x509_att.c:106:19: 
    104.   X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
    105.   {
    106. > 	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
    107.   		return NULL;
    108.   	else

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 false branch
      301.   int sk_num(const STACK *st)
      302.   {
      303.   	if(st == NULL) return -1;
                 ^
      304.   	return st->num;
      305.   }

crypto/stack/stack.c:304:2: 
      302.   {
      303.   	if(st == NULL) return -1;
      304. > 	return st->num;
      305.   }
      306.   

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_att.c:106:19: Taking false branch
    104.   X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
    105.   {
    106.   	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
                             ^
    107.   		return NULL;
    108.   	else

crypto/x509/x509_att.c:106:54: Taking true branch
    104.   X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
    105.   {
    106.   	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
                                                                ^
    107.   		return NULL;
    108.   	else

crypto/x509/x509_att.c:107:3: 
    105.   {
    106.   	if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
    107. > 		return NULL;
    108.   	else
    109.   		return sk_X509_ATTRIBUTE_value(x,loc);

crypto/x509/x509_att.c:110:1: return from a call to X509at_get_attr
    108.   	else
    109.   		return sk_X509_ATTRIBUTE_value(x,loc);
    110. > }
    111.   
    112.   X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc)

crypto/x509/x509_req.c:278:1: return from a call to X509_REQ_get_attr
  276.   {
  277.   	return X509at_get_attr(req->req_info->attributes, loc);
  278. > }
  279.   
  280.   X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc)

crypto/x509/x509_req.c:201:6: Taking false branch
199.   			continue;
200.   		attr = X509_REQ_get_attr(req, idx);
201.   		if(attr->single) ext = attr->value.single;
            ^
202.   		else if(sk_ASN1_TYPE_num(attr->value.set))
203.   			ext = sk_ASN1_TYPE_value(attr->value.set, 0);

STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
	{
	X509_ATTRIBUTE *attr;
	ASN1_TYPE *ext = NULL;
	int idx, *pnid;
	const unsigned char *p;
	if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
		return(NULL);
	for (pnid = ext_nids; *pnid != NID_undef; pnid++)
		{
		idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);
		if (idx == -1)
			continue;
		attr = X509_REQ_get_attr(req, idx);
		if(attr->single) ext = attr->value.single;
		else if(sk_ASN1_TYPE_num(attr->value.set))
			ext = sk_ASN1_TYPE_value(attr->value.set, 0);
		break;
		}
	if(!ext || (ext->type != V_ASN1_SEQUENCE))
		return NULL;
	p = ext->value.sequence->data;
	return (STACK_OF(X509_EXTENSION) *)
		ASN1_item_d2i(NULL, &p, ext->value.sequence->length,
				ASN1_ITEM_rptr(X509_EXTENSIONS));
}
['STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)\n\t{\n\tX509_ATTRIBUTE *attr;\n\tASN1_TYPE *ext = NULL;\n\tint idx, *pnid;\n\tconst unsigned char *p;\n\tif ((req == NULL) || (req->req_info == NULL) || !ext_nids)\n\t\treturn(NULL);\n\tfor (pnid = ext_nids; *pnid != NID_undef; pnid++)\n\t\t{\n\t\tidx = X509_REQ_get_attr_by_NID(req, *pnid, -1);\n\t\tif (idx == -1)\n\t\t\tcontinue;\n\t\tattr = X509_REQ_get_attr(req, idx);\n\t\tif(attr->single) ext = attr->value.single;\n\t\telse if(sk_ASN1_TYPE_num(attr->value.set))\n\t\t\text = sk_ASN1_TYPE_value(attr->value.set, 0);\n\t\tbreak;\n\t\t}\n\tif(!ext || (ext->type != V_ASN1_SEQUENCE))\n\t\treturn NULL;\n\tp = ext->value.sequence->data;\n\treturn (STACK_OF(X509_EXTENSION) *)\n\t\tASN1_item_d2i(NULL, &p, ext->value.sequence->length,\n\t\t\t\tASN1_ITEM_rptr(X509_EXTENSIONS));\n}', 'int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,\n\t\t\t  int lastpos)\n{\n\treturn X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos);\n}', 'int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n\t\t\t  int lastpos)\n{\n\tASN1_OBJECT *obj;\n\tobj=OBJ_nid2obj(nid);\n\tif (obj == NULL) return(-2);\n\treturn(X509at_get_attr_by_OBJ(x,obj,lastpos));\n}', 'ASN1_OBJECT *OBJ_nid2obj(int n)\n\t{\n\tADDED_OBJ ad,*adp;\n\tASN1_OBJECT ob;\n\tif ((n >= 0) && (n < NUM_NID))\n\t\t{\n\t\tif ((n != NID_undef) && (nid_objs[n].nid == NID_undef))\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\treturn((ASN1_OBJECT *)&(nid_objs[n]));\n\t\t}\n\telse if (added == NULL)\n\t\treturn(NULL);\n\telse\n\t\t{\n\t\tad.type=ADDED_NID;\n\t\tad.obj= &ob;\n\t\tob.nid=n;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,&ad);\n\t\tif (adp != NULL)\n\t\t\treturn(adp->obj);\n\t\telse\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\t}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_flags[es->top]=0;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}', 'X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc)\n{\n\treturn X509at_get_attr(req->req_info->attributes, loc);\n}', 'X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)\n{\n\tif (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)\n\t\treturn NULL;\n\telse\n\t\treturn sk_X509_ATTRIBUTE_value(x,loc);\n}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}']