crypto/x509/x509_vfy.c:2120: error: NULL_DEREFERENCE
  pointer `ptmp` last assigned on line 2119 could be null and is dereferenced at line 2120, column 13.
Showing all 34 steps of the trace


crypto/x509/x509_vfy.c:2103:1: start of procedure X509_STORE_CTX_purpose_inherit()
2101.    */
2102.   
2103. > int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
2104.                                      int purpose, int trust)
2105.   {

crypto/x509/x509_vfy.c:2108:10: Taking false branch
2106.       int idx;
2107.       /* If purpose not set use default */
2108.       if (!purpose)
                 ^
2109.           purpose = def_purpose;
2110.       /* If we have a purpose then check it is valid */

crypto/x509/x509_vfy.c:2111:9: Taking true branch
2109.           purpose = def_purpose;
2110.       /* If we have a purpose then check it is valid */
2111.       if (purpose) {
                ^
2112.           X509_PURPOSE *ptmp;
2113.           idx = X509_PURPOSE_get_by_id(purpose);

crypto/x509/x509_vfy.c:2113:9: 
2111.       if (purpose) {
2112.           X509_PURPOSE *ptmp;
2113. >         idx = X509_PURPOSE_get_by_id(purpose);
2114.           if (idx == -1) {
2115.               X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,

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:448:1: start of procedure sk_X509_PURPOSE_find()
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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 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/x509v3.h:448:1: return from a call to sk_X509_PURPOSE_find
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   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/x509/x509_vfy.c:2114:13: Taking false branch
2112.           X509_PURPOSE *ptmp;
2113.           idx = X509_PURPOSE_get_by_id(purpose);
2114.           if (idx == -1) {
                    ^
2115.               X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
2116.                       X509_R_UNKNOWN_PURPOSE_ID);

crypto/x509/x509_vfy.c:2119:9: 
2117.               return 0;
2118.           }
2119. >         ptmp = X509_PURPOSE_get0(idx);
2120.           if (ptmp->trust == X509_TRUST_DEFAULT) {
2121.               idx = X509_PURPOSE_get_by_id(def_purpose);

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/x509/x509_vfy.c:2120:13: 
2118.           }
2119.           ptmp = X509_PURPOSE_get0(idx);
2120. >         if (ptmp->trust == X509_TRUST_DEFAULT) {
2121.               idx = X509_PURPOSE_get_by_id(def_purpose);
2122.               /*
