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


crypto/x509/x509_lu.c:568:1: start of procedure X509_OBJECT_retrieve_match()
566.   }
567.   
568. > X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
569.                                           X509_OBJECT *x)
570.   {

crypto/x509/x509_lu.c:573:5: 
571.       int idx, i;
572.       X509_OBJECT *obj;
573. >     idx = sk_X509_OBJECT_find(h, x);
574.       if (idx == -1)
575.           return NULL;

include/openssl/x509_vfy.h:54:1: start of procedure sk_X509_OBJECT_find()
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

crypto/stack/stack.c:202:1: start of procedure OPENSSL_sk_find()
    200.   }
    201.   
    202. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    203.   {
    204.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:204:5: 
    202.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    203.   {
    204. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    205.   }
    206.   

crypto/stack/stack.c:177:1: start of procedure internal_find()
      175.   }
      176.   
      177. > static int internal_find(OPENSSL_STACK *st, const void *data,
      178.                            int ret_val_options)
      179.   {

crypto/stack/stack.c:183:9: Taking false branch
      181.       int i;
      182.   
      183.       if (st == NULL)
                     ^
      184.           return -1;
      185.   

crypto/stack/stack.c:186:9: Taking true branch
      184.           return -1;
      185.   
      186.       if (st->comp == NULL) {
                     ^
      187.           for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)

crypto/stack/stack.c:187:14: 
      185.   
      186.       if (st->comp == NULL) {
      187. >         for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)
      189.                   return (i);

crypto/stack/stack.c:187:21: Loop condition is true. Entering loop body
      185.   
      186.       if (st->comp == NULL) {
      187.           for (i = 0; i < st->num; i++)
                                 ^
      188.               if (st->data[i] == data)
      189.                   return (i);

crypto/stack/stack.c:188:17: Taking false branch
      186.       if (st->comp == NULL) {
      187.           for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)
                             ^
      189.                   return (i);
      190.           return (-1);

crypto/stack/stack.c:187:34: 
      185.   
      186.       if (st->comp == NULL) {
      187. >         for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)
      189.                   return (i);

crypto/stack/stack.c:187:21: Loop condition is true. Entering loop body
      185.   
      186.       if (st->comp == NULL) {
      187.           for (i = 0; i < st->num; i++)
                                 ^
      188.               if (st->data[i] == data)
      189.                   return (i);

crypto/stack/stack.c:188:17: Taking true branch
      186.       if (st->comp == NULL) {
      187.           for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)
                             ^
      189.                   return (i);
      190.           return (-1);

crypto/stack/stack.c:189:17: 
      187.           for (i = 0; i < st->num; i++)
      188.               if (st->data[i] == data)
      189. >                 return (i);
      190.           return (-1);
      191.       }

crypto/stack/stack.c:200:1: return from a call to internal_find
      198.           return (-1);
      199.       return (int)((char **)r - st->data);
      200. > }
      201.   
      202.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)

crypto/stack/stack.c:205:1: return from a call to OPENSSL_sk_find
    203.   {
    204.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    205. > }
    206.   
    207.   int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data)

include/openssl/x509_vfy.h:54:1: return from a call to sk_X509_OBJECT_find
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

crypto/x509/x509_lu.c:574:9: Taking false branch
572.       X509_OBJECT *obj;
573.       idx = sk_X509_OBJECT_find(h, x);
574.       if (idx == -1)
               ^
575.           return NULL;
576.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))

crypto/x509/x509_lu.c:576:10: Taking false branch
574.       if (idx == -1)
575.           return NULL;
576.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
                ^
577.           return sk_X509_OBJECT_value(h, idx);
578.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {

crypto/x509/x509_lu.c:578:10: 
576.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
577.           return sk_X509_OBJECT_value(h, idx);
578. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
579.           obj = sk_X509_OBJECT_value(h, i);
580.           if (x509_object_cmp

crypto/x509/x509_lu.c:578:19: 
576.       if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
577.           return sk_X509_OBJECT_value(h, idx);
578. >     for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
579.           obj = sk_X509_OBJECT_value(h, i);
580.           if (x509_object_cmp

include/openssl/x509_vfy.h:54:1: start of procedure sk_X509_OBJECT_num()
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

crypto/stack/stack.c:270:1: start of procedure OPENSSL_sk_num()
    268.   }
    269.   
    270. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    271.   {
    272.       if (st == NULL)

crypto/stack/stack.c:272:9: Taking false branch
    270.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    271.   {
    272.       if (st == NULL)
                   ^
    273.           return -1;
    274.       return st->num;

crypto/stack/stack.c:274:5: 
    272.       if (st == NULL)
    273.           return -1;
    274. >     return st->num;
    275.   }
    276.   

crypto/stack/stack.c:275:1: return from a call to OPENSSL_sk_num
    273.           return -1;
    274.       return st->num;
    275. > }
    276.   
    277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509_vfy.h:54:1: return from a call to sk_X509_OBJECT_num
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

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

crypto/x509/x509_lu.c:579:9: 
577.           return sk_X509_OBJECT_value(h, idx);
578.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
579. >         obj = sk_X509_OBJECT_value(h, i);
580.           if (x509_object_cmp
581.               ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))

include/openssl/x509_vfy.h:54:1: start of procedure sk_X509_OBJECT_value()
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_value()
    275.   }
    276.   
    277. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:279:9: Taking false branch
    277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    280.           return NULL;
    281.       return st->data[i];

crypto/stack/stack.c:279:23: Taking true branch
    277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)
                                 ^
    280.           return NULL;
    281.       return st->data[i];

crypto/stack/stack.c:280:9: 
    278.   {
    279.       if (st == NULL || i < 0 || i >= st->num)
    280. >         return NULL;
    281.       return st->data[i];
    282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_value
    280.           return NULL;
    281.       return st->data[i];
    282. > }
    283.   
    284.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)

include/openssl/x509_vfy.h:54:1: return from a call to sk_X509_OBJECT_value
  52.   
  53.   DEFINE_STACK_OF(X509_LOOKUP)
  54. > DEFINE_STACK_OF(X509_OBJECT)
  55.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  56.   

crypto/x509/x509_lu.c:580:13: 
578.       for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
579.           obj = sk_X509_OBJECT_value(h, i);
580. >         if (x509_object_cmp
581.               ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
582.               return NULL;

crypto/x509/x509_lu.c:109:1: start of procedure x509_object_cmp()
  107.   }
  108.   
  109. > static int x509_object_cmp(const X509_OBJECT *const *a,
  110.                              const X509_OBJECT *const *b)
  111.   {

crypto/x509/x509_lu.c:114:5: 
  112.       int ret;
  113.   
  114. >     ret = ((*a)->type - (*b)->type);
  115.       if (ret)
  116.           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 *const *r;\n    int i;\n    if (st == NULL)\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    OPENSSL_sk_sort(st);\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    if (r == NULL)\n        return (-1);\n    return (int)((char **)r - st->data);\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return 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 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    default:\n        return 0;\n    }\n    return ret;\n}']