crypto/x509v3/v3_purp.c:93: error: NULL_DEREFERENCE
  pointer `pt` last assigned on line 92 could be null and is dereferenced at line 93, column 12.
Showing all 36 steps of the trace


crypto/x509v3/v3_purp.c:77:1: start of procedure X509_check_purpose()
75.    * things.
76.    */
77. > int X509_check_purpose(X509 *x, int id, int ca)
78.   {
79.       int idx;

crypto/x509v3/v3_purp.c:81:11: Taking false branch
79.       int idx;
80.       const X509_PURPOSE *pt;
81.       if (!(x->ex_flags & EXFLAG_SET)) {
                ^
82.           CRYPTO_THREAD_write_lock(x->lock);
83.           x509v3_cache_extensions(x);

crypto/x509v3/v3_purp.c:87:9: Taking false branch
85.       }
86.       /* Return if side-effect only call */
87.       if (id == -1)
              ^
88.           return 1;
89.       idx = X509_PURPOSE_get_by_id(id);

crypto/x509v3/v3_purp.c:89:5: 
87.       if (id == -1)
88.           return 1;
89. >     idx = X509_PURPOSE_get_by_id(id);
90.       if (idx == -1)
91.           return -1;

crypto/x509v3/v3_purp.c:134:1: start of procedure X509_PURPOSE_get_by_id()
  132.   }
  133.   
  134. > int X509_PURPOSE_get_by_id(int purpose)
  135.   {
  136.       X509_PURPOSE tmp;

crypto/x509v3/v3_purp.c:138:10: Taking true branch
  136.       X509_PURPOSE tmp;
  137.       int idx;
  138.       if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
                  ^
  139.           return purpose - X509_PURPOSE_MIN;
  140.       tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:138:43: Taking false branch
  136.       X509_PURPOSE tmp;
  137.       int idx;
  138.       if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
                                                   ^
  139.           return purpose - X509_PURPOSE_MIN;
  140.       tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:140:5: 
  138.       if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
  139.           return purpose - X509_PURPOSE_MIN;
  140. >     tmp.purpose = purpose;
  141.       if (!xptable)
  142.           return -1;

crypto/x509v3/v3_purp.c:141:10: Taking false branch
  139.           return purpose - X509_PURPOSE_MIN;
  140.       tmp.purpose = purpose;
  141.       if (!xptable)
                  ^
  142.           return -1;
  143.       idx = sk_X509_PURPOSE_find(xptable, &tmp);

crypto/x509v3/v3_purp.c:143:5: 
  141.       if (!xptable)
  142.           return -1;
  143. >     idx = sk_X509_PURPOSE_find(xptable, &tmp);
  144.       if (idx == -1)
  145.           return -1;

include/openssl/x509v3.h:451:1: start of procedure sk_X509_PURPOSE_find()
    449.   # define X509V3_ADD_SILENT               0x10
    450.   
    451. > DEFINE_STACK_OF(X509_PURPOSE)
    452.   
    453.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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/x509v3.h:451:1: return from a call to sk_X509_PURPOSE_find
    449.   # define X509V3_ADD_SILENT               0x10
    450.   
    451. > DEFINE_STACK_OF(X509_PURPOSE)
    452.   
    453.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/x509v3/v3_purp.c:144:9: Taking false branch
  142.           return -1;
  143.       idx = sk_X509_PURPOSE_find(xptable, &tmp);
  144.       if (idx == -1)
                 ^
  145.           return -1;
  146.       return idx + X509_PURPOSE_COUNT;

crypto/x509v3/v3_purp.c:146:5: 
  144.       if (idx == -1)
  145.           return -1;
  146. >     return idx + X509_PURPOSE_COUNT;
  147.   }
  148.   

crypto/x509v3/v3_purp.c:147:1: return from a call to X509_PURPOSE_get_by_id
  145.           return -1;
  146.       return idx + X509_PURPOSE_COUNT;
  147. > }
  148.   
  149.   int X509_PURPOSE_add(int id, int trust, int flags,

crypto/x509v3/v3_purp.c:90:9: Taking false branch
88.           return 1;
89.       idx = X509_PURPOSE_get_by_id(id);
90.       if (idx == -1)
              ^
91.           return -1;
92.       pt = X509_PURPOSE_get0(idx);

crypto/x509v3/v3_purp.c:92:5: 
90.       if (idx == -1)
91.           return -1;
92. >     pt = X509_PURPOSE_get0(idx);
93.       return pt->check_purpose(pt, x, ca);
94.   }

crypto/x509v3/v3_purp.c:113:1: start of procedure X509_PURPOSE_get0()
  111.   }
  112.   
  113. > X509_PURPOSE *X509_PURPOSE_get0(int idx)
  114.   {
  115.       if (idx < 0)

crypto/x509v3/v3_purp.c:115:9: Taking true branch
  113.   X509_PURPOSE *X509_PURPOSE_get0(int idx)
  114.   {
  115.       if (idx < 0)
                 ^
  116.           return NULL;
  117.       if (idx < (int)X509_PURPOSE_COUNT)

crypto/x509v3/v3_purp.c:116:9: 
  114.   {
  115.       if (idx < 0)
  116. >         return NULL;
  117.       if (idx < (int)X509_PURPOSE_COUNT)
  118.           return xstandard + idx;

crypto/x509v3/v3_purp.c:120:1: return from a call to X509_PURPOSE_get0
  118.           return xstandard + idx;
  119.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  120. > }
  121.   
  122.   int X509_PURPOSE_get_by_sname(const char *sname)

crypto/x509v3/v3_purp.c:93:5: 
91.           return -1;
92.       pt = X509_PURPOSE_get0(idx);
93. >     return pt->check_purpose(pt, x, ca);
94.   }
95.   

int X509_check_purpose(X509 *x, int id, int ca)
{
    int idx;
    const X509_PURPOSE *pt;
    if (!(x->ex_flags & EXFLAG_SET)) {
        CRYPTO_THREAD_write_lock(x->lock);
        x509v3_cache_extensions(x);
        CRYPTO_THREAD_unlock(x->lock);
    }
    if (id == -1)
        return 1;
    idx = X509_PURPOSE_get_by_id(id);
    if (idx == -1)
        return -1;
    pt = X509_PURPOSE_get0(idx);
    return pt->check_purpose(pt, x, ca);
}
['int X509_check_purpose(X509 *x, int id, int ca)\n{\n    int idx;\n    const X509_PURPOSE *pt;\n    if (!(x->ex_flags & EXFLAG_SET)) {\n        CRYPTO_THREAD_write_lock(x->lock);\n        x509v3_cache_extensions(x);\n        CRYPTO_THREAD_unlock(x->lock);\n    }\n    if (id == -1)\n        return 1;\n    idx = X509_PURPOSE_get_by_id(id);\n    if (idx == -1)\n        return -1;\n    pt = X509_PURPOSE_get0(idx);\n    return pt->check_purpose(pt, x, ca);\n}', 'int X509_PURPOSE_get_by_id(int purpose)\n{\n    X509_PURPOSE tmp;\n    int idx;\n    if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))\n        return purpose - X509_PURPOSE_MIN;\n    tmp.purpose = purpose;\n    if (!xptable)\n        return -1;\n    idx = sk_X509_PURPOSE_find(xptable, &tmp);\n    if (idx == -1)\n        return -1;\n    return idx + X509_PURPOSE_COUNT;\n}', 'DEFINE_STACK_OF(X509_PURPOSE)', '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}', 'X509_PURPOSE *X509_PURPOSE_get0(int idx)\n{\n    if (idx < 0)\n        return NULL;\n    if (idx < (int)X509_PURPOSE_COUNT)\n        return xstandard + idx;\n    return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);\n}']