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


crypto/pkcs7/pk7_doit.c:1080:1: start of procedure PKCS7_get_issuer_and_serial()
1078.   }
1079.   
1080. > PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
1081.   {
1082.       STACK_OF(PKCS7_RECIP_INFO) *rsk;

crypto/pkcs7/pk7_doit.c:1086:5: 
1084.       int i;
1085.   
1086. >     i = OBJ_obj2nid(p7->type);
1087.       if (i != NID_pkcs7_signedAndEnveloped)
1088.           return NULL;

crypto/objects/obj_dat.c:390:1: start of procedure OBJ_obj2nid()
  388.   IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
  389.   
  390. > int OBJ_obj2nid(const ASN1_OBJECT *a)
  391.   {
  392.       const unsigned int *op;

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

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

crypto/objects/obj_dat.c:400:9: Taking false branch
  398.           return (a->nid);
  399.   
  400.       if (a->length == 0)
                 ^
  401.           return NID_undef;
  402.   

crypto/objects/obj_dat.c:403:9: Taking true branch
  401.           return NID_undef;
  402.   
  403.       if (added != NULL) {
                 ^
  404.           ad.type = ADDED_DATA;
  405.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */

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

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

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

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

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

crypto/lhash/lhash.c:217:1: start of procedure lh_retrieve()
    215.   }
    216.   
    217. > void *lh_retrieve(_LHASH *lh, const void *data)
    218.   {
    219.       unsigned long hash;

crypto/lhash/lhash.c:223:5: 
    221.       void *ret;
    222.   
    223. >     lh->error = 0;
    224.       rn = getrn(lh, data, &hash);
    225.   

crypto/lhash/lhash.c:224:5: Skipping getrn(): empty list of specs
    222.   
    223.       lh->error = 0;
    224.       rn = getrn(lh, data, &hash);
               ^
    225.   
    226.       if (*rn == NULL) {

crypto/lhash/lhash.c:226:9: Taking false branch
    224.       rn = getrn(lh, data, &hash);
    225.   
    226.       if (*rn == NULL) {
                   ^
    227.           lh->num_retrieve_miss++;
    228.           return (NULL);

crypto/lhash/lhash.c:230:9: 
    228.           return (NULL);
    229.       } else {
    230. >         ret = (*rn)->data;
    231.           lh->num_retrieve++;
    232.       }

crypto/lhash/lhash.c:231:9: 
    229.       } else {
    230.           ret = (*rn)->data;
    231. >         lh->num_retrieve++;
    232.       }
    233.       return (ret);

crypto/lhash/lhash.c:233:5: 
    231.           lh->num_retrieve++;
    232.       }
    233. >     return (ret);
    234.   }
    235.   

crypto/lhash/lhash.c:234:1: return from a call to lh_retrieve
    232.       }
    233.       return (ret);
    234. > }
    235.   
    236.   static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

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

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

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

crypto/pkcs7/pk7_doit.c:1087:9: Taking false branch
1085.   
1086.       i = OBJ_obj2nid(p7->type);
1087.       if (i != NID_pkcs7_signedAndEnveloped)
                ^
1088.           return NULL;
1089.       if (p7->d.signed_and_enveloped == NULL)

crypto/pkcs7/pk7_doit.c:1089:9: Taking false branch
1087.       if (i != NID_pkcs7_signedAndEnveloped)
1088.           return NULL;
1089.       if (p7->d.signed_and_enveloped == NULL)
                ^
1090.           return NULL;
1091.       rsk = p7->d.signed_and_enveloped->recipientinfo;

crypto/pkcs7/pk7_doit.c:1091:5: 
1089.       if (p7->d.signed_and_enveloped == NULL)
1090.           return NULL;
1091. >     rsk = p7->d.signed_and_enveloped->recipientinfo;
1092.       if (rsk == NULL)
1093.           return NULL;

crypto/pkcs7/pk7_doit.c:1092:9: Taking false branch
1090.           return NULL;
1091.       rsk = p7->d.signed_and_enveloped->recipientinfo;
1092.       if (rsk == NULL)
                ^
1093.           return NULL;
1094.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)

crypto/pkcs7/pk7_doit.c:1094:9: Condition is true
1092.       if (rsk == NULL)
1093.           return NULL;
1094.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
                ^
1095.           return (NULL);
1096.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);

crypto/stack/stack.c:317:1: start of procedure sk_num()
  315.   }
  316.   
  317. > int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)

crypto/stack/stack.c:319:9: Taking false branch
  317.   int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)
                 ^
  320.           return -1;
  321.       return st->num;

crypto/stack/stack.c:321:5: 
  319.       if (st == NULL)
  320.           return -1;
  321. >     return st->num;
  322.   }
  323.   

crypto/stack/stack.c:322:1: return from a call to sk_num
  320.           return -1;
  321.       return st->num;
  322. > }
  323.   
  324.   void *sk_value(const _STACK *st, int i)

crypto/pkcs7/pk7_doit.c:1094:9: Taking false branch
1092.       if (rsk == NULL)
1093.           return NULL;
1094.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
                ^
1095.           return (NULL);
1096.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);

crypto/pkcs7/pk7_doit.c:1096:10: Condition is true
1094.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1095.           return (NULL);
1096.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
                 ^
1097.       return (ri->issuer_and_serial);
1098.   }

crypto/pkcs7/pk7_doit.c:1096:5: 
1094.       if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
1095.           return (NULL);
1096. >     ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
1097.       return (ri->issuer_and_serial);
1098.   }

crypto/stack/stack.c:324:1: start of procedure sk_value()
  322.   }
  323.   
  324. > void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:326:10: Taking false branch
  324.   void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
                  ^
  327.           return NULL;
  328.       return st->data[i];

crypto/stack/stack.c:326:17: Taking true branch
  324.   void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
                         ^
  327.           return NULL;
  328.       return st->data[i];

crypto/stack/stack.c:327:9: 
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
  327. >         return NULL;
  328.       return st->data[i];
  329.   }

crypto/stack/stack.c:329:1: return from a call to sk_value
  327.           return NULL;
  328.       return st->data[i];
  329. > }
  330.   
  331.   void *sk_set(_STACK *st, int i, void *value)

crypto/pkcs7/pk7_doit.c:1097:5: 
1095.           return (NULL);
1096.       ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);
1097. >     return (ri->issuer_and_serial);
1098.   }
1099.   

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;
    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    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 (a->length == 0)\n        return NID_undef;\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}', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\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}']