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


crypto/pkcs7/pk7_doit.c:1095:1: start of procedure PKCS7_get_issuer_and_serial()
1093.   	}
1094.   
1095. > PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
1096.   	{
1097.   	STACK_OF(PKCS7_RECIP_INFO) *rsk;

crypto/pkcs7/pk7_doit.c:1101:2: 
1099.   	int i;
1100.   
1101. > 	i=OBJ_obj2nid(p7->type);
1102.   	if (i != NID_pkcs7_signedAndEnveloped)
1103.   		return NULL;

crypto/objects/obj_dat.c:388:1: start of procedure OBJ_obj2nid()
  386.   	}
  387.   
  388. > int OBJ_obj2nid(const ASN1_OBJECT *a)
  389.   	{
  390.   	const unsigned int *op;

crypto/objects/obj_dat.c:393:6: Taking false branch
  391.   	ADDED_OBJ ad,*adp;
  392.   
  393.   	if (a == NULL)
              ^
  394.   		return(NID_undef);
  395.   	if (a->nid != 0)

crypto/objects/obj_dat.c:395:6: Taking false branch
  393.   	if (a == NULL)
  394.   		return(NID_undef);
  395.   	if (a->nid != 0)
              ^
  396.   		return(a->nid);
  397.   

crypto/objects/obj_dat.c:398:6: Taking true branch
  396.   		return(a->nid);
  397.   
  398.   	if (added != NULL)
              ^
  399.   		{
  400.   		ad.type=ADDED_DATA;

crypto/objects/obj_dat.c:400:3: 
  398.   	if (added != NULL)
  399.   		{
  400. > 		ad.type=ADDED_DATA;
  401.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  402.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);

crypto/objects/obj_dat.c:401:3: 
  399.   		{
  400.   		ad.type=ADDED_DATA;
  401. > 		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  402.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  403.   		if (adp != NULL) return (adp->obj->nid);

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

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

crypto/objects/obj_dat.c:402:3: 
  400.   		ad.type=ADDED_DATA;
  401.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  402. > 		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  403.   		if (adp != NULL) return (adp->obj->nid);
  404.   		}

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:403:7: Taking true branch
  401.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  402.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  403.   		if (adp != NULL) return (adp->obj->nid);
               ^
  404.   		}
  405.   	op=(const unsigned int *)OBJ_bsearch((const char *)&a,(const char *)obj_objs,

crypto/objects/obj_dat.c:403:20: 
  401.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  402.   		adp=lh_ADDED_OBJ_retrieve(added,&ad);
  403. > 		if (adp != NULL) return (adp->obj->nid);
  404.   		}
  405.   	op=(const unsigned int *)OBJ_bsearch((const char *)&a,(const char *)obj_objs,

crypto/objects/obj_dat.c:410:2: return from a call to OBJ_obj2nid
  408.   		return(NID_undef);
  409.   	return(nid_objs[*op].nid);
  410.   	}
          ^
  411.   
  412.   /* Convert an object name into an ASN1_OBJECT

crypto/pkcs7/pk7_doit.c:1102:6: Taking false branch
1100.   
1101.   	i=OBJ_obj2nid(p7->type);
1102.   	if (i != NID_pkcs7_signedAndEnveloped)
             ^
1103.   		return NULL;
1104.   	if (p7->d.signed_and_enveloped == NULL)

crypto/pkcs7/pk7_doit.c:1104:6: Taking false branch
1102.   	if (i != NID_pkcs7_signedAndEnveloped)
1103.   		return NULL;
1104.   	if (p7->d.signed_and_enveloped == NULL)
             ^
1105.   		return NULL;
1106.   	rsk=p7->d.signed_and_enveloped->recipientinfo;

crypto/pkcs7/pk7_doit.c:1106:2: 
1104.   	if (p7->d.signed_and_enveloped == NULL)
1105.   		return NULL;
1106. > 	rsk=p7->d.signed_and_enveloped->recipientinfo;
1107.   	if (rsk == NULL)
1108.   		return NULL;

crypto/pkcs7/pk7_doit.c:1107:6: Taking false branch
1105.   		return NULL;
1106.   	rsk=p7->d.signed_and_enveloped->recipientinfo;
1107.   	if (rsk == NULL)
             ^
1108.   		return NULL;
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);

crypto/pkcs7/pk7_doit.c:1109:5: Condition is true
1107.   	if (rsk == NULL)
1108.   		return NULL;
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
            ^
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);

crypto/pkcs7/pk7_doit.c:1109:2: 
1107.   	if (rsk == NULL)
1108.   		return NULL;
1109. > 	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);

crypto/stack/stack.c:308:1: start of procedure sk_value()
  306.   }
  307.   
  308. > void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:310:6: Taking false branch
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:13: Taking false branch
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:24: Taking false branch
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:311:2: 
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311. > 	return st->data[i];
  312.   }
  313.   

crypto/stack/stack.c:312:1: return from a call to sk_value
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312. > }
  313.   
  314.   void *sk_set(_STACK *st, int i, void *value)

crypto/pkcs7/pk7_doit.c:1110:6: Condition is true
1108.   		return NULL;
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
             ^
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1112.   	return(ri->issuer_and_serial);

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

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

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

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

crypto/pkcs7/pk7_doit.c:1110:6: Taking false branch
1108.   		return NULL;
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
             ^
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1112.   	return(ri->issuer_and_serial);

crypto/pkcs7/pk7_doit.c:1111:5: Condition is true
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
            ^
1112.   	return(ri->issuer_and_serial);
1113.   	}

crypto/pkcs7/pk7_doit.c:1111:2: 
1109.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,0);
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1111. > 	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1112.   	return(ri->issuer_and_serial);
1113.   	}

crypto/stack/stack.c:308:1: start of procedure sk_value()
  306.   }
  307.   
  308. > void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:310:6: Taking false branch
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:13: Taking true branch
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:39: 
  308.   void *sk_value(const _STACK *st, int i)
  309.   {
  310. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:312:1: return from a call to sk_value
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312. > }
  313.   
  314.   void *sk_set(_STACK *st, int i, void *value)

crypto/pkcs7/pk7_doit.c:1112:2: 
1110.   	if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return(NULL);
1111.   	ri=sk_PKCS7_RECIP_INFO_value(rsk,idx);
1112. > 	return(ri->issuer_and_serial);
1113.   	}
1114.   

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=(const unsigned int *)OBJ_bsearch((const char *)&a,(const char *)obj_objs,\n\t\tNUM_OBJ, sizeof(obj_objs[0]),obj_cmp);\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}']