crypto/x509/x509_lu.c:567: error: NULL_DEREFERENCE
  pointer `&obj` last assigned on line 566 could be null and is dereferenced by call to `x509_object_cmp()` at line 567, column 13.
Showing all 41 steps of the trace


crypto/x509/x509_lu.c:555:1: start of procedure X509_OBJECT_retrieve_match()
553.   }
554.   
555. > X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
556.                                           X509_OBJECT *x)
557.   {

crypto/x509/x509_lu.c:560:5: 
558.       int idx, i;
559.       X509_OBJECT *obj;
560. >     idx = sk_X509_OBJECT_find(h, x);
561.       if (idx == -1)
562.           return NULL;

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_find()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:311:1: start of procedure OPENSSL_sk_find()
    309.   }
    310.   
    311. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    312.   {
    313.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:313:5: 
    311.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    312.   {
    313. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    314.   }
    315.   

crypto/stack/stack.c:282:1: start of procedure internal_find()
      280.   }
      281.   
      282. > static int internal_find(OPENSSL_STACK *st, const void *data,
      283.                            int ret_val_options)
      284.   {

crypto/stack/stack.c:288:9: Taking false branch
      286.       int i;
      287.   
      288.       if (st == NULL || st->num == 0)
                     ^
      289.           return -1;
      290.   

crypto/stack/stack.c:288:23: Taking false branch
      286.       int i;
      287.   
      288.       if (st == NULL || st->num == 0)
                                   ^
      289.           return -1;
      290.   

crypto/stack/stack.c:291:9: Taking true branch
      289.           return -1;
      290.   
      291.       if (st->comp == NULL) {
                     ^
      292.           for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)

crypto/stack/stack.c:292:14: 
      290.   
      291.       if (st->comp == NULL) {
      292. >         for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)
      294.                   return i;

crypto/stack/stack.c:292:21: Loop condition is true. Entering loop body
      290.   
      291.       if (st->comp == NULL) {
      292.           for (i = 0; i < st->num; i++)
                                 ^
      293.               if (st->data[i] == data)
      294.                   return i;

crypto/stack/stack.c:293:17: Taking false branch
      291.       if (st->comp == NULL) {
      292.           for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)
                             ^
      294.                   return i;
      295.           return -1;

crypto/stack/stack.c:292:34: 
      290.   
      291.       if (st->comp == NULL) {
      292. >         for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)
      294.                   return i;

crypto/stack/stack.c:292:21: Loop condition is true. Entering loop body
      290.   
      291.       if (st->comp == NULL) {
      292.           for (i = 0; i < st->num; i++)
                                 ^
      293.               if (st->data[i] == data)
      294.                   return i;

crypto/stack/stack.c:293:17: Taking true branch
      291.       if (st->comp == NULL) {
      292.           for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)
                             ^
      294.                   return i;
      295.           return -1;

crypto/stack/stack.c:294:17: 
      292.           for (i = 0; i < st->num; i++)
      293.               if (st->data[i] == data)
      294. >                 return i;
      295.           return -1;
      296.       }

crypto/stack/stack.c:309:1: return from a call to internal_find
      307.   
      308.       return r == NULL ? -1 : (int)((const void **)r - st->data);
      309. > }
      310.   
      311.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)

crypto/stack/stack.c:314:1: return from a call to OPENSSL_sk_find
    312.   {
    313.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    314. > }
    315.   
    316.   int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_find
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:561:9: Taking false branch
559.       X509_OBJECT *obj;
560.       idx = sk_X509_OBJECT_find(h, x);
561.       if (idx == -1)
               ^
562.           return NULL;
563.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))

crypto/x509/x509_lu.c:563:10: Taking false branch
561.       if (idx == -1)
562.           return NULL;
563.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
                ^
564.           return sk_X509_OBJECT_value(h, idx);
565.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {

crypto/x509/x509_lu.c:565:10: 
563.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
564.           return sk_X509_OBJECT_value(h, idx);
565. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
566.           obj = sk_X509_OBJECT_value(h, i);
567.           if (x509_object_cmp

crypto/x509/x509_lu.c:565:19: 
563.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
564.           return sk_X509_OBJECT_value(h, idx);
565. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
566.           obj = sk_X509_OBJECT_value(h, i);
567.           if (x509_object_cmp

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_num()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:375:1: start of procedure OPENSSL_sk_num()
    373.   }
    374.   
    375. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    376.   {
    377.       return st == NULL ? -1 : st->num;

crypto/stack/stack.c:377:12: Condition is false
    375.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    376.   {
    377.       return st == NULL ? -1 : st->num;
                      ^
    378.   }
    379.   

crypto/stack/stack.c:377:5: 
    375.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    376.   {
    377. >     return st == NULL ? -1 : st->num;
    378.   }
    379.   

crypto/stack/stack.c:378:1: return from a call to OPENSSL_sk_num
    376.   {
    377.       return st == NULL ? -1 : st->num;
    378. > }
    379.   
    380.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_num
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:565:19: Loop condition is true. Entering loop body
563.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
564.           return sk_X509_OBJECT_value(h, idx);
565.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
                         ^
566.           obj = sk_X509_OBJECT_value(h, i);
567.           if (x509_object_cmp

crypto/x509/x509_lu.c:566:9: 
564.           return sk_X509_OBJECT_value(h, idx);
565.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
566. >         obj = sk_X509_OBJECT_value(h, i);
567.           if (x509_object_cmp
568.               ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_value()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:380:1: start of procedure OPENSSL_sk_value()
    378.   }
    379.   
    380. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:382:9: Taking false branch
    380.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    383.           return NULL;
    384.       return (void *)st->data[i];

crypto/stack/stack.c:382:23: Taking true branch
    380.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)
                                 ^
    383.           return NULL;
    384.       return (void *)st->data[i];

crypto/stack/stack.c:383:9: 
    381.   {
    382.       if (st == NULL || i < 0 || i >= st->num)
    383. >         return NULL;
    384.       return (void *)st->data[i];
    385.   }

crypto/stack/stack.c:385:1: return from a call to OPENSSL_sk_value
    383.           return NULL;
    384.       return (void *)st->data[i];
    385. > }
    386.   
    387.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_value
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:567:13: 
565.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
566.           obj = sk_X509_OBJECT_value(h, i);
567. >         if (x509_object_cmp
568.               ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
569.               return NULL;

crypto/x509/x509_lu.c:120:1: start of procedure x509_object_cmp()
  118.   }
  119.   
  120. > static int x509_object_cmp(const X509_OBJECT *const *a,
  121.                              const X509_OBJECT *const *b)
  122.   {

crypto/x509/x509_lu.c:125:5: 
  123.       int ret;
  124.   
  125. >     ret = ((*a)->type - (*b)->type);
  126.       if (ret)
  127.           return ret;

X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
                                        X509_OBJECT *x)
{
    int idx, i;
    X509_OBJECT *obj;
    idx = sk_X509_OBJECT_find(h, x);
    if (idx == -1)
        return NULL;
    if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
        return sk_X509_OBJECT_value(h, idx);
    for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
        obj = sk_X509_OBJECT_value(h, i);
        if (x509_object_cmp
            ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
            return NULL;
        if (x->type == X509_LU_X509) {
            if (!X509_cmp(obj->data.x509, x->data.x509))
                return obj;
        } else if (x->type == X509_LU_CRL) {
            if (!X509_CRL_match(obj->data.crl, x->data.crl))
                return obj;
        } else
            return obj;
    }
    return NULL;
}
['X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x)\n{\n    int idx, i;\n    X509_OBJECT *obj;\n    idx = sk_X509_OBJECT_find(h, x);\n    if (idx == -1)\n        return NULL;\n    if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))\n        return sk_X509_OBJECT_value(h, idx);\n    for (i = idx; i < sk_X509_OBJECT_num(h); i++) {\n        obj = sk_X509_OBJECT_value(h, i);\n        if (x509_object_cmp\n            ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))\n            return NULL;\n        if (x->type == X509_LU_X509) {\n            if (!X509_cmp(obj->data.x509, x->data.x509))\n                return obj;\n        } else if (x->type == X509_LU_CRL) {\n            if (!X509_CRL_match(obj->data.crl, x->data.crl))\n                return obj;\n        } else\n            return obj;\n    }\n    return NULL;\n}', 'int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(OPENSSL_STACK *st, const void *data,\n                         int ret_val_options)\n{\n    const void *r;\n    int i;\n    if (st == NULL || st->num == 0)\n        return -1;\n    if (st->comp == NULL) {\n        for (i = 0; i < st->num; i++)\n            if (st->data[i] == data)\n                return i;\n        return -1;\n    }\n    if (!st->sorted) {\n        if (st->num > 1)\n            qsort(st->data, st->num, sizeof(void *), st->comp);\n        st->sorted = 1;\n    }\n    if (data == NULL)\n        return -1;\n    r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp,\n                        ret_val_options);\n    return r == NULL ? -1 : (int)((const void **)r - st->data);\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    return st == NULL ? -1 : st->num;\n}', 'void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)\n{\n    if (st == NULL || i < 0 || i >= st->num)\n        return NULL;\n    return (void *)st->data[i];\n}', 'static int x509_object_cmp(const X509_OBJECT *const *a,\n                           const X509_OBJECT *const *b)\n{\n    int ret;\n    ret = ((*a)->type - (*b)->type);\n    if (ret)\n        return ret;\n    switch ((*a)->type) {\n    case X509_LU_X509:\n        ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);\n        break;\n    case X509_LU_CRL:\n        ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);\n        break;\n    case X509_LU_NONE:\n        return 0;\n    }\n    return ret;\n}']