crypto/pkcs7/pk7_doit.c:1122: error: NULL_DEREFERENCE
  pointer `ri` last assigned on line 1121 could be null and is dereferenced at line 1122, column 8.
Showing all 48 steps of the trace


crypto/pkcs7/pk7_doit.c:1105:1: start of procedure PKCS7_get_issuer_and_serial()
1103.   	}
1104.   
1105. > PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
1106.   	{
1107.   	STACK_OF(PKCS7_RECIP_INFO) *rsk;

crypto/pkcs7/pk7_doit.c:1111:2: 
1109.   	int i;
1110.   
1111. > 	i=OBJ_obj2nid(p7->type);
1112.   	if (i != NID_pkcs7_signedAndEnveloped)
1113.   		return NULL;

crypto/objects/obj_dat.c:398:1: start of procedure OBJ_obj2nid()
  396.   IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
  397.   
  398. > int OBJ_obj2nid(const ASN1_OBJECT *a)
  399.   	{
  400.   	const unsigned int *op;

crypto/objects/obj_dat.c:403:6: Taking false branch
  401.   	ADDED_OBJ ad,*adp;
  402.   
  403.   	if (a == NULL)
              ^
  404.   		return(NID_undef);
  405.   	if (a->nid != 0)

crypto/objects/obj_dat.c:405:6: Taking false branch
  403.   	if (a == NULL)
  404.   		return(NID_undef);
  405.   	if (a->nid != 0)
              ^
  406.   		return(a->nid);
  407.   

crypto/objects/obj_dat.c:408:6: Taking true branch
  406.   		return(a->nid);
  407.   
  408.   	if (added != NULL)
              ^
  409.   		{
  410.   		ad.type=ADDED_DATA;

crypto/objects/obj_dat.c:410:3: 
  408.   	if (added != NULL)
  409.   		{
  410. > 		ad.type=ADDED_DATA;
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);

crypto/objects/obj_dat.c:411:3: 
  409.   		{
  410.   		ad.type=ADDED_DATA;
  411. > 		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  413.   		if (adp != NULL) return (adp->obj->nid);

crypto/objects/obj_dat.c:412:7: Condition is true
  410.   		ad.type=ADDED_DATA;
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
               ^
  413.   		if (adp != NULL) return (adp->obj->nid);
  414.   		}

crypto/objects/obj_dat.c:412:7: Condition is true
  410.   		ad.type=ADDED_DATA;
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
               ^
  413.   		if (adp != NULL) return (adp->obj->nid);
  414.   		}

crypto/objects/obj_dat.c:412:3: 
  410.   		ad.type=ADDED_DATA;
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412. > 		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  413.   		if (adp != NULL) return (adp->obj->nid);
  414.   		}

crypto/lhash/lhash.c:248:1: start of procedure lh_retrieve()
    246.   	}
    247.   
    248. > void *lh_retrieve(_LHASH *lh, const void *data)
    249.   	{
    250.   	unsigned long hash;

crypto/lhash/lhash.c:254:2: 
    252.   	void *ret;
    253.   
    254. > 	lh->error=0;
    255.   	rn=getrn(lh,data,&hash);
    256.   

crypto/lhash/lhash.c:255:2: Skipping getrn(): empty list of specs
    253.   
    254.   	lh->error=0;
    255.   	rn=getrn(lh,data,&hash);
            ^
    256.   
    257.   	if (*rn == NULL)

crypto/lhash/lhash.c:257:6: Taking false branch
    255.   	rn=getrn(lh,data,&hash);
    256.   
    257.   	if (*rn == NULL)
                ^
    258.   		{
    259.   		lh->num_retrieve_miss++;

crypto/lhash/lhash.c:264:3: 
    262.   	else
    263.   		{
    264. > 		ret= (*rn)->data;
    265.   		lh->num_retrieve++;
    266.   		}

crypto/lhash/lhash.c:265:3: 
    263.   		{
    264.   		ret= (*rn)->data;
    265. > 		lh->num_retrieve++;
    266.   		}
    267.   	return(ret);

crypto/lhash/lhash.c:267:2: 
    265.   		lh->num_retrieve++;
    266.   		}
    267. > 	return(ret);
    268.   	}
    269.   

crypto/lhash/lhash.c:268:2: return from a call to lh_retrieve
    266.   		}
    267.   	return(ret);
    268.   	}
            ^
    269.   
    270.   static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

crypto/objects/obj_dat.c:413:7: Taking true branch
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  413.   		if (adp != NULL) return (adp->obj->nid);
               ^
  414.   		}
  415.   	op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);

crypto/objects/obj_dat.c:413:20: 
  411.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  412.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  413. > 		if (adp != NULL) return (adp->obj->nid);
  414.   		}
  415.   	op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);

crypto/objects/obj_dat.c:419:2: return from a call to OBJ_obj2nid
  417.   		return(NID_undef);
  418.   	return(nid_objs[*op].nid);
  419.   	}
          ^
  420.   
  421.   /* Convert an object name into an ASN1_OBJECT

crypto/pkcs7/pk7_doit.c:1112:6: Taking false branch
1110.   
1111.   	i=OBJ_obj2nid(p7->type);
1112.   	if (i != NID_pkcs7_signedAndEnveloped)
             ^
1113.   		return NULL;
1114.   	if (p7->d.signed_and_enveloped == NULL)

crypto/pkcs7/pk7_doit.c:1114:6: Taking false branch
1112.   	if (i != NID_pkcs7_signedAndEnveloped)
1113.   		return NULL;
1114.   	if (p7->d.signed_and_enveloped == NULL)
             ^
1115.   		return NULL;
1116.   	rsk=p7->d.signed_and_enveloped->recipientinfo;

crypto/pkcs7/pk7_doit.c:1116:2: 
1114.   	if (p7->d.signed_and_enveloped == NULL)
1115.   		return NULL;
1116. > 	rsk=p7->d.signed_and_enveloped->recipientinfo;
1117.   	if (rsk == NULL)
1118.   		return NULL;

crypto/pkcs7/pk7_doit.c:1117:6: Taking false branch
1115.   		return NULL;
1116.   	rsk=p7->d.signed_and_enveloped->recipientinfo;
1117.   	if (rsk == NULL)
             ^
1118.   		return NULL;
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);

crypto/pkcs7/pk7_doit.c:1119:5: Condition is true
1117.   	if (rsk == NULL)
1118.   		return NULL;
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
            ^
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);

crypto/pkcs7/pk7_doit.c:1119:2: 
1117.   	if (rsk == NULL)
1118.   		return NULL;
1119. > 	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);

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/pkcs7/pk7_doit.c:1120:6: Condition is true
1118.   		return NULL;
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
             ^
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1122.   	return(ri->issuer_and_serial);

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/pkcs7/pk7_doit.c:1120:6: Taking false branch
1118.   		return NULL;
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
             ^
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1122.   	return(ri->issuer_and_serial);

crypto/pkcs7/pk7_doit.c:1121:5: Condition is true
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
            ^
1122.   	return(ri->issuer_and_serial);
1123.   	}

crypto/pkcs7/pk7_doit.c:1121:2: 
1119.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1121. > 	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1122.   	return(ri->issuer_and_serial);
1123.   	}

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/pkcs7/pk7_doit.c:1122:2: 
1120.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1121.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1122. > 	return(ri->issuer_and_serial);
1123.   	}
1124.   

PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
	{
	STACK_OF(PKCS7_RECIP_INFO) *rsk;
	PKCS7_RECIP_INFO *ri;
	int i;
	i=OBJ_obj2nid(p7->type);
	if (i != NID_pkcs7_signedAndEnveloped)
		return NULL;
	if (p7->d.signed_and_enveloped == NULL)
		return NULL;
	rsk=p7->d.signed_and_enveloped->recipientinfo;
	if (rsk == NULL)
		return NULL;
	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
	return(ri->issuer_and_serial);
	}
['PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)\n\t{\n\tSTACK_OF(PKCS7_RECIP_INFO) *rsk;\n\tPKCS7_RECIP_INFO *ri;\n\tint i;\n\ti=OBJ_obj2nid(p7->type);\n\tif (i != NID_pkcs7_signedAndEnveloped)\n\t\treturn NULL;\n\tif (p7->d.signed_and_enveloped == NULL)\n\t\treturn NULL;\n\trsk=p7->d.signed_and_enveloped->recipientinfo;\n\tif (rsk == NULL)\n\t\treturn NULL;\n\tri=sk_PKCS7_RECIP_INFO_value(rsk,0);\n\tif (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);\n\tri=sk_PKCS7_RECIP_INFO_value(rsk,idx);\n\treturn(ri->issuer_and_serial);\n\t}', 'int OBJ_obj2nid(const ASN1_OBJECT *a)\n\t{\n\tconst unsigned int *op;\n\tADDED_OBJ ad,*adp;\n\tif (a == NULL)\n\t\treturn(NID_undef);\n\tif (a->nid != 0)\n\t\treturn(a->nid);\n\tif (added != NULL)\n\t\t{\n\t\tad.type=ADDED_DATA;\n\t\tad.obj=(ASN1_OBJECT *)a;\n\t\tadp=lh_ADDED_OBJ_retrieve(added,&ad);\n\t\tif (adp != NULL) return (adp->obj->nid);\n\t\t}\n\top=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);\n\tif (op == NULL)\n\t\treturn(NID_undef);\n\treturn(nid_objs[*op].nid);\n\t}', 'void *lh_retrieve(_LHASH *lh, const void *data)\n\t{\n\tunsigned long hash;\n\tLHASH_NODE **rn;\n\tvoid *ret;\n\tlh->error=0;\n\trn=getrn(lh,data,&hash);\n\tif (*rn == NULL)\n\t\t{\n\t\tlh->num_retrieve_miss++;\n\t\treturn(NULL);\n\t\t}\n\telse\n\t\t{\n\t\tret= (*rn)->data;\n\t\tlh->num_retrieve++;\n\t\t}\n\treturn(ret);\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}']