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


crypto/x509/x509_lu.c:563:1: start of procedure X509_OBJECT_retrieve_match()
561.   }
562.   
563. > X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
564.                                           X509_OBJECT *x)
565.   {

crypto/x509/x509_lu.c:568:5: 
566.       int idx, i;
567.       X509_OBJECT *obj;
568. >     idx = sk_X509_OBJECT_find(h, x);
569.       if (idx == -1)
570.           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:312:1: start of procedure OPENSSL_sk_find()
    310.   }
    311.   
    312. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    313.   {
    314.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/stack/stack.c:315:1: return from a call to OPENSSL_sk_find
    313.   {
    314.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    315. > }
    316.   
    317.   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:569:9: Taking false branch
567.       X509_OBJECT *obj;
568.       idx = sk_X509_OBJECT_find(h, x);
569.       if (idx == -1)
               ^
570.           return NULL;
571.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))

crypto/x509/x509_lu.c:571:10: Taking false branch
569.       if (idx == -1)
570.           return NULL;
571.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
                ^
572.           return sk_X509_OBJECT_value(h, idx);
573.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {

crypto/x509/x509_lu.c:573:10: 
571.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
572.           return sk_X509_OBJECT_value(h, idx);
573. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
574.           obj = sk_X509_OBJECT_value(h, i);
575.           if (x509_object_cmp

crypto/x509/x509_lu.c:573:19: 
571.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
572.           return sk_X509_OBJECT_value(h, idx);
573. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
574.           obj = sk_X509_OBJECT_value(h, i);
575.           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:376:1: start of procedure OPENSSL_sk_num()
    374.   }
    375.   
    376. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    377.   {
    378.       return st == NULL ? -1 : st->num;

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

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

crypto/stack/stack.c:379:1: return from a call to OPENSSL_sk_num
    377.   {
    378.       return st == NULL ? -1 : st->num;
    379. > }
    380.   
    381.   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:573:19: Loop condition is true. Entering loop body
571.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
572.           return sk_X509_OBJECT_value(h, idx);
573.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
                         ^
574.           obj = sk_X509_OBJECT_value(h, i);
575.           if (x509_object_cmp

crypto/x509/x509_lu.c:574:9: 
572.           return sk_X509_OBJECT_value(h, idx);
573.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
574. >         obj = sk_X509_OBJECT_value(h, i);
575.           if (x509_object_cmp
576.               ((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:381:1: start of procedure OPENSSL_sk_value()
    379.   }
    380.   
    381. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    382.   {
    383.       if (st == NULL || i < 0 || i >= st->num)

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

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

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

crypto/stack/stack.c:386:1: return from a call to OPENSSL_sk_value
    384.           return NULL;
    385.       return (void *)st->data[i];
    386. > }
    387.   
    388.   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:575:13: 
573.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
574.           obj = sk_X509_OBJECT_value(h, i);
575. >         if (x509_object_cmp
576.               ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
577.               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}']