crypto/x509/x509_trs.c:131: error: NULL_DEREFERENCE
  pointer `pt` last assigned on line 130 could be null and is dereferenced at line 131, column 12.
Showing all 32 steps of the trace


crypto/x509/x509_trs.c:114:1: start of procedure X509_check_trust()
112.   }
113.   
114. > int X509_check_trust(X509 *x, int id, int flags)
115.   {
116.       X509_TRUST *pt;

crypto/x509/x509_trs.c:120:9: Taking false branch
118.   
119.       /* We get this as a default value */
120.       if (id == 0) {
               ^
121.           int rv;
122.           rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);

crypto/x509/x509_trs.c:127:5: 
125.           return trust_compat(NULL, x, 0);
126.       }
127. >     idx = X509_TRUST_get_by_id(id);
128.       if (idx == -1)
129.           return default_trust(id, x, flags);

crypto/x509/x509_trs.c:150:1: start of procedure X509_TRUST_get_by_id()
  148.   }
  149.   
  150. > int X509_TRUST_get_by_id(int id)
  151.   {
  152.       X509_TRUST tmp;

crypto/x509/x509_trs.c:154:10: Taking true branch
  152.       X509_TRUST tmp;
  153.       int idx;
  154.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
                  ^
  155.           return id - X509_TRUST_MIN;
  156.       tmp.trust = id;

crypto/x509/x509_trs.c:154:36: Taking false branch
  152.       X509_TRUST tmp;
  153.       int idx;
  154.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
                                            ^
  155.           return id - X509_TRUST_MIN;
  156.       tmp.trust = id;

crypto/x509/x509_trs.c:156:5: 
  154.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
  155.           return id - X509_TRUST_MIN;
  156. >     tmp.trust = id;
  157.       if (!trtable)
  158.           return -1;

crypto/x509/x509_trs.c:157:10: Taking false branch
  155.           return id - X509_TRUST_MIN;
  156.       tmp.trust = id;
  157.       if (!trtable)
                  ^
  158.           return -1;
  159.       idx = sk_X509_TRUST_find(trtable, &tmp);

crypto/x509/x509_trs.c:159:5: 
  157.       if (!trtable)
  158.           return -1;
  159. >     idx = sk_X509_TRUST_find(trtable, &tmp);
  160.       if (idx == -1)
  161.           return -1;

include/openssl/x509.h:182:1: start of procedure sk_X509_TRUST_find()
    180.   } X509_TRUST;
    181.   
    182. > DEFINE_STACK_OF(X509_TRUST)
    183.   
    184.   /* standard trust ids */

crypto/stack/stack.c:248:1: start of procedure sk_find()
      246.   }
      247.   
      248. > int sk_find(_STACK *st, void *data)
      249.   {
      250.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:250:5: 
      248.   int sk_find(_STACK *st, void *data)
      249.   {
      250. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
      251.   }
      252.   

crypto/stack/stack.c:224:1: start of procedure internal_find()
        222.   }
        223.   
        224. > static int internal_find(_STACK *st, void *data, int ret_val_options)
        225.   {
        226.       const void *const *r;

crypto/stack/stack.c:229:9: Taking false branch
        227.       int i;
        228.   
        229.       if (st == NULL)
                       ^
        230.           return -1;
        231.   

crypto/stack/stack.c:232:9: Taking true branch
        230.           return -1;
        231.   
        232.       if (st->comp == NULL) {
                       ^
        233.           for (i = 0; i < st->num; i++)
        234.               if (st->data[i] == data)

crypto/stack/stack.c:233:14: 
        231.   
        232.       if (st->comp == NULL) {
        233. >         for (i = 0; i < st->num; i++)
        234.               if (st->data[i] == data)
        235.                   return (i);

crypto/stack/stack.c:233:21: Loop condition is true. Entering loop body
        231.   
        232.       if (st->comp == NULL) {
        233.           for (i = 0; i < st->num; i++)
                                   ^
        234.               if (st->data[i] == data)
        235.                   return (i);

crypto/stack/stack.c:234:17: Taking true branch
        232.       if (st->comp == NULL) {
        233.           for (i = 0; i < st->num; i++)
        234.               if (st->data[i] == data)
                               ^
        235.                   return (i);
        236.           return (-1);

crypto/stack/stack.c:235:17: 
        233.           for (i = 0; i < st->num; i++)
        234.               if (st->data[i] == data)
        235. >                 return (i);
        236.           return (-1);
        237.       }

crypto/stack/stack.c:246:1: return from a call to internal_find
        244.           return (-1);
        245.       return (int)((char **)r - st->data);
        246. > }
        247.   
        248.   int sk_find(_STACK *st, void *data)

crypto/stack/stack.c:251:1: return from a call to sk_find
      249.   {
      250.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
      251. > }
      252.   
      253.   int sk_find_ex(_STACK *st, void *data)

include/openssl/x509.h:182:1: return from a call to sk_X509_TRUST_find
    180.   } X509_TRUST;
    181.   
    182. > DEFINE_STACK_OF(X509_TRUST)
    183.   
    184.   /* standard trust ids */

crypto/x509/x509_trs.c:160:9: Taking false branch
  158.           return -1;
  159.       idx = sk_X509_TRUST_find(trtable, &tmp);
  160.       if (idx == -1)
                 ^
  161.           return -1;
  162.       return idx + X509_TRUST_COUNT;

crypto/x509/x509_trs.c:162:5: 
  160.       if (idx == -1)
  161.           return -1;
  162. >     return idx + X509_TRUST_COUNT;
  163.   }
  164.   

crypto/x509/x509_trs.c:163:1: return from a call to X509_TRUST_get_by_id
  161.           return -1;
  162.       return idx + X509_TRUST_COUNT;
  163. > }
  164.   
  165.   int X509_TRUST_set(int *t, int trust)

crypto/x509/x509_trs.c:128:9: Taking false branch
126.       }
127.       idx = X509_TRUST_get_by_id(id);
128.       if (idx == -1)
               ^
129.           return default_trust(id, x, flags);
130.       pt = X509_TRUST_get0(idx);

crypto/x509/x509_trs.c:130:5: 
128.       if (idx == -1)
129.           return default_trust(id, x, flags);
130. >     pt = X509_TRUST_get0(idx);
131.       return pt->check_trust(pt, x, flags);
132.   }

crypto/x509/x509_trs.c:141:1: start of procedure X509_TRUST_get0()
  139.   }
  140.   
  141. > X509_TRUST *X509_TRUST_get0(int idx)
  142.   {
  143.       if (idx < 0)

crypto/x509/x509_trs.c:143:9: Taking true branch
  141.   X509_TRUST *X509_TRUST_get0(int idx)
  142.   {
  143.       if (idx < 0)
                 ^
  144.           return NULL;
  145.       if (idx < (int)X509_TRUST_COUNT)

crypto/x509/x509_trs.c:144:9: 
  142.   {
  143.       if (idx < 0)
  144. >         return NULL;
  145.       if (idx < (int)X509_TRUST_COUNT)
  146.           return trstandard + idx;

crypto/x509/x509_trs.c:148:1: return from a call to X509_TRUST_get0
  146.           return trstandard + idx;
  147.       return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);
  148. > }
  149.   
  150.   int X509_TRUST_get_by_id(int id)

crypto/x509/x509_trs.c:131:5: 
129.           return default_trust(id, x, flags);
130.       pt = X509_TRUST_get0(idx);
131. >     return pt->check_trust(pt, x, flags);
132.   }
133.   

int X509_check_trust(X509 *x, int id, int flags)
{
    X509_TRUST *pt;
    int idx;
    if (id == 0) {
        int rv;
        rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);
        if (rv != X509_TRUST_UNTRUSTED)
            return rv;
        return trust_compat(NULL, x, 0);
    }
    idx = X509_TRUST_get_by_id(id);
    if (idx == -1)
        return default_trust(id, x, flags);
    pt = X509_TRUST_get0(idx);
    return pt->check_trust(pt, x, flags);
}
['int X509_check_trust(X509 *x, int id, int flags)\n{\n    X509_TRUST *pt;\n    int idx;\n    if (id == 0) {\n        int rv;\n        rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);\n        if (rv != X509_TRUST_UNTRUSTED)\n            return rv;\n        return trust_compat(NULL, x, 0);\n    }\n    idx = X509_TRUST_get_by_id(id);\n    if (idx == -1)\n        return default_trust(id, x, flags);\n    pt = X509_TRUST_get0(idx);\n    return pt->check_trust(pt, x, flags);\n}', 'int X509_TRUST_get_by_id(int id)\n{\n    X509_TRUST tmp;\n    int idx;\n    if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))\n        return id - X509_TRUST_MIN;\n    tmp.trust = id;\n    if (!trtable)\n        return -1;\n    idx = sk_X509_TRUST_find(trtable, &tmp);\n    if (idx == -1)\n        return -1;\n    return idx + X509_TRUST_COUNT;\n}', 'int sk_find(_STACK *st, void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(_STACK *st, void *data, 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    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}', 'X509_TRUST *X509_TRUST_get0(int idx)\n{\n    if (idx < 0)\n        return NULL;\n    if (idx < (int)X509_TRUST_COUNT)\n        return trstandard + idx;\n    return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);\n}']