crypto/x509v3/v3_purp.c:174: error: NULL_DEREFERENCE
  pointer `ptmp` last assigned on line 171 could be null and is dereferenced at line 174, column 9.
Showing all 11 steps of the trace


crypto/x509v3/v3_purp.c:149:1: start of procedure X509_PURPOSE_add()
147.   }
148.   
149. > int X509_PURPOSE_add(int id, int trust, int flags,
150.                        int (*ck) (const X509_PURPOSE *, const X509 *, int),
151.                        const char *name, const char *sname, void *arg)

crypto/x509v3/v3_purp.c:158:5: 
156.        * This is set according to what we change: application can't set it
157.        */
158. >     flags &= ~X509_PURPOSE_DYNAMIC;
159.       /* This will always be set for application modified trust entries */
160.       flags |= X509_PURPOSE_DYNAMIC_NAME;

crypto/x509v3/v3_purp.c:160:5: 
158.       flags &= ~X509_PURPOSE_DYNAMIC;
159.       /* This will always be set for application modified trust entries */
160. >     flags |= X509_PURPOSE_DYNAMIC_NAME;
161.       /* Get existing entry if any */
162.       idx = X509_PURPOSE_get_by_id(id);

crypto/x509v3/v3_purp.c:162:5: Skipping X509_PURPOSE_get_by_id(): empty list of specs
160.       flags |= X509_PURPOSE_DYNAMIC_NAME;
161.       /* Get existing entry if any */
162.       idx = X509_PURPOSE_get_by_id(id);
           ^
163.       /* Need a new entry */
164.       if (idx == -1) {

crypto/x509v3/v3_purp.c:164:9: Taking false branch
162.       idx = X509_PURPOSE_get_by_id(id);
163.       /* Need a new entry */
164.       if (idx == -1) {
               ^
165.           if ((ptmp = OPENSSL_malloc(sizeof(*ptmp))) == NULL) {
166.               X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_purp.c:171:9: 
169.           ptmp->flags = X509_PURPOSE_DYNAMIC;
170.       } else
171. >         ptmp = X509_PURPOSE_get0(idx);
172.   
173.       /* OPENSSL_free existing name if dynamic */

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

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

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

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

crypto/x509v3/v3_purp.c:174:9: 
172.   
173.       /* OPENSSL_free existing name if dynamic */
174. >     if (ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
175.           OPENSSL_free(ptmp->name);
176.           OPENSSL_free(ptmp->sname);
