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


crypto/pkcs7/pk7_doit.c:1087:1: start of procedure PKCS7_get_issuer_and_serial()
1085.   }
1086.   
1087. > PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
1088.   {
1089.       STACK_OF(PKCS7_RECIP_INFO) *rsk;

crypto/pkcs7/pk7_doit.c:1093:5: 
1091.       int i;
1092.   
1093. >     i = OBJ_obj2nid(p7->type);
1094.       if (i != NID_pkcs7_signedAndEnveloped)
1095.           return NULL;

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

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

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

crypto/objects/obj_dat.c:406:9: Taking true branch
  404.           return (a->nid);
  405.   
  406.       if (added != NULL) {
                 ^
  407.           ad.type = ADDED_DATA;
  408.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */

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

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

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

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

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

crypto/lhash/lhash.c:239:1: start of procedure lh_retrieve()
    237.   }
    238.   
    239. > void *lh_retrieve(_LHASH *lh, const void *data)
    240.   {
    241.       unsigned long hash;

crypto/lhash/lhash.c:245:5: 
    243.       void *ret;
    244.   
    245. >     lh->error = 0;
    246.       rn = getrn(lh, data, &hash);
    247.   

crypto/lhash/lhash.c:246:5: Skipping getrn(): empty list of specs
    244.   
    245.       lh->error = 0;
    246.       rn = getrn(lh, data, &hash);
               ^
    247.   
    248.       if (*rn == NULL) {

crypto/lhash/lhash.c:248:9: Taking false branch
    246.       rn = getrn(lh, data, &hash);
    247.   
    248.       if (*rn == NULL) {
                   ^
    249.           lh->num_retrieve_miss++;
    250.           return (NULL);

crypto/lhash/lhash.c:252:9: 
    250.           return (NULL);
    251.       } else {
    252. >         ret = (*rn)->data;
    253.           lh->num_retrieve++;
    254.       }

crypto/lhash/lhash.c:253:9: 
    251.       } else {
    252.           ret = (*rn)->data;
    253. >         lh->num_retrieve++;
    254.       }
    255.       return (ret);

crypto/lhash/lhash.c:255:5: 
    253.           lh->num_retrieve++;
    254.       }
    255. >     return (ret);
    256.   }
    257.   

crypto/lhash/lhash.c:256:1: return from a call to lh_retrieve
    254.       }
    255.       return (ret);
    256. > }
    257.   
    258.   static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

crypto/objects/obj_dat.c:410:13: Taking true branch
  408.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  409.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  410.           if (adp != NULL)
                     ^
  411.               return (adp->obj->nid);
  412.       }

crypto/objects/obj_dat.c:411:13: 
  409.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  410.           if (adp != NULL)
  411. >             return (adp->obj->nid);
  412.       }
  413.       op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);

crypto/objects/obj_dat.c:417:1: return from a call to OBJ_obj2nid
  415.           return (NID_undef);
  416.       return (nid_objs[*op].nid);
  417. > }
  418.   
  419.   /*

crypto/pkcs7/pk7_doit.c:1094:9: Taking false branch
1092.   
1093.       i = OBJ_obj2nid(p7->type);
1094.       if (i != NID_pkcs7_signedAndEnveloped)
                ^
1095.           return NULL;
1096.       if (p7->d.signed_and_enveloped == NULL)

crypto/pkcs7/pk7_doit.c:1096:9: Taking false branch
1094.       if (i != NID_pkcs7_signedAndEnveloped)
1095.           return NULL;
1096.       if (p7->d.signed_and_enveloped == NULL)
                ^
1097.           return NULL;
1098.       rsk = p7->d.signed_and_enveloped->recipientinfo;

crypto/pkcs7/pk7_doit.c:1098:5: 
1096.       if (p7->d.signed_and_enveloped == NULL)
1097.           return NULL;
1098. >     rsk = p7->d.signed_and_enveloped->recipientinfo;
1099.       if (rsk == NULL)
1100.           return NULL;

crypto/pkcs7/pk7_doit.c:1099:9: Taking false branch
1097.           return NULL;
1098.       rsk = p7->d.signed_and_enveloped->recipientinfo;
1099.       if (rsk == NULL)
                ^
1100.           return NULL;
1101.       ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);

crypto/pkcs7/pk7_doit.c:1101:10: Condition is true
1099.       if (rsk == NULL)
1100.           return NULL;
1101.       ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);
                 ^
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1103.           return (NULL);

crypto/pkcs7/pk7_doit.c:1101:5: 
1099.       if (rsk == NULL)
1100.           return NULL;
1101. >     ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1103.           return (NULL);

crypto/stack/stack.c:334:1: start of procedure sk_value()
  332.   }
  333.   
  334. > void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:336:10: Taking false branch
  334.   void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
                  ^
  337.           return NULL;
  338.       return st->data[i];

crypto/stack/stack.c:336:17: Taking false branch
  334.   void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
                         ^
  337.           return NULL;
  338.       return st->data[i];

crypto/stack/stack.c:336:28: Taking false branch
  334.   void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
                                    ^
  337.           return NULL;
  338.       return st->data[i];

crypto/stack/stack.c:338:5: 
  336.       if (!st || (i < 0) || (i >= st->num))
  337.           return NULL;
  338. >     return st->data[i];
  339.   }
  340.   

crypto/stack/stack.c:339:1: return from a call to sk_value
  337.           return NULL;
  338.       return st->data[i];
  339. > }
  340.   
  341.   void *sk_set(_STACK *st, int i, void *value)

crypto/pkcs7/pk7_doit.c:1102:9: Condition is true
1100.           return NULL;
1101.       ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
                ^
1103.           return (NULL);
1104.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);

crypto/stack/stack.c:327:1: start of procedure sk_num()
  325.   }
  326.   
  327. > int sk_num(const _STACK *st)
  328.   {
  329.       if (st == NULL)

crypto/stack/stack.c:329:9: Taking false branch
  327.   int sk_num(const _STACK *st)
  328.   {
  329.       if (st == NULL)
                 ^
  330.           return -1;
  331.       return st->num;

crypto/stack/stack.c:331:5: 
  329.       if (st == NULL)
  330.           return -1;
  331. >     return st->num;
  332.   }
  333.   

crypto/stack/stack.c:332:1: return from a call to sk_num
  330.           return -1;
  331.       return st->num;
  332. > }
  333.   
  334.   void *sk_value(const _STACK *st, int i)

crypto/pkcs7/pk7_doit.c:1102:9: Taking false branch
1100.           return NULL;
1101.       ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
                ^
1103.           return (NULL);
1104.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);

crypto/pkcs7/pk7_doit.c:1104:10: Condition is true
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1103.           return (NULL);
1104.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
                 ^
1105.       return (ri->issuer_and_serial);
1106.   }

crypto/pkcs7/pk7_doit.c:1104:5: 
1102.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1103.           return (NULL);
1104. >     ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
1105.       return (ri->issuer_and_serial);
1106.   }

crypto/stack/stack.c:334:1: start of procedure sk_value()
  332.   }
  333.   
  334. > void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:336:10: Taking false branch
  334.   void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
                  ^
  337.           return NULL;
  338.       return st->data[i];

crypto/stack/stack.c:336:17: Taking true branch
  334.   void *sk_value(const _STACK *st, int i)
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
                         ^
  337.           return NULL;
  338.       return st->data[i];

crypto/stack/stack.c:337:9: 
  335.   {
  336.       if (!st || (i < 0) || (i >= st->num))
  337. >         return NULL;
  338.       return st->data[i];
  339.   }

crypto/stack/stack.c:339:1: return from a call to sk_value
  337.           return NULL;
  338.       return st->data[i];
  339. > }
  340.   
  341.   void *sk_set(_STACK *st, int i, void *value)

crypto/pkcs7/pk7_doit.c:1105:5: 
1103.           return (NULL);
1104.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
1105. >     return (ri->issuer_and_serial);
1106.   }
1107.   

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{\n    STACK_OF(PKCS7_RECIP_INFO) *rsk;\n    PKCS7_RECIP_INFO *ri;\n    int i;\n    i = OBJ_obj2nid(p7->type);\n    if (i != NID_pkcs7_signedAndEnveloped)\n        return NULL;\n    if (p7->d.signed_and_enveloped == NULL)\n        return NULL;\n    rsk = p7->d.signed_and_enveloped->recipientinfo;\n    if (rsk == NULL)\n        return NULL;\n    ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);\n    if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)\n        return (NULL);\n    ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);\n    return (ri->issuer_and_serial);\n}', 'int OBJ_obj2nid(const ASN1_OBJECT *a)\n{\n    const unsigned int *op;\n    ADDED_OBJ ad, *adp;\n    if (a == NULL)\n        return (NID_undef);\n    if (a->nid != 0)\n        return (a->nid);\n    if (added != NULL) {\n        ad.type = ADDED_DATA;\n        ad.obj = (ASN1_OBJECT *)a;\n        adp = lh_ADDED_OBJ_retrieve(added, &ad);\n        if (adp != NULL)\n            return (adp->obj->nid);\n    }\n    op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);\n    if (op == NULL)\n        return (NID_undef);\n    return (nid_objs[*op].nid);\n}', 'void *lh_retrieve(_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    LHASH_NODE **rn;\n    void *ret;\n    lh->error = 0;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        lh->num_retrieve_miss++;\n        return (NULL);\n    } else {\n        ret = (*rn)->data;\n        lh->num_retrieve++;\n    }\n    return (ret);\n}', 'void *sk_value(const _STACK *st, int i)\n{\n    if (!st || (i < 0) || (i >= st->num))\n        return NULL;\n    return st->data[i];\n}', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}']