crypto/x509/x509_trs.c:146: error: NULL_DEREFERENCE
  pointer `trtmp` last assigned on line 143 could be null and is dereferenced at line 146, column 9.
Showing all 36 steps of the trace


crypto/x509/x509_trs.c:122:1: start of procedure X509_TRUST_add()
120.   }
121.   
122. > int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
123.                      const char *name, int arg1, void *arg2)
124.   {

crypto/x509/x509_trs.c:130:5: 
128.        * This is set according to what we change: application can't set it
129.        */
130. >     flags &= ~X509_TRUST_DYNAMIC;
131.       /* This will always be set for application modified trust entries */
132.       flags |= X509_TRUST_DYNAMIC_NAME;

crypto/x509/x509_trs.c:132:5: 
130.       flags &= ~X509_TRUST_DYNAMIC;
131.       /* This will always be set for application modified trust entries */
132. >     flags |= X509_TRUST_DYNAMIC_NAME;
133.       /* Get existing entry if any */
134.       idx = X509_TRUST_get_by_id(id);

crypto/x509/x509_trs.c:134:5: 
132.       flags |= X509_TRUST_DYNAMIC_NAME;
133.       /* Get existing entry if any */
134. >     idx = X509_TRUST_get_by_id(id);
135.       /* Need a new entry */
136.       if (idx == -1) {

crypto/x509/x509_trs.c:97:1: start of procedure X509_TRUST_get_by_id()
  95.   }
  96.   
  97. > int X509_TRUST_get_by_id(int id)
  98.   {
  99.       X509_TRUST tmp;

crypto/x509/x509_trs.c:101:10: Taking true branch
  99.       X509_TRUST tmp;
  100.       int idx;
  101.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
                  ^
  102.           return id - X509_TRUST_MIN;
  103.       tmp.trust = id;

crypto/x509/x509_trs.c:101:36: Taking false branch
  99.       X509_TRUST tmp;
  100.       int idx;
  101.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
                                            ^
  102.           return id - X509_TRUST_MIN;
  103.       tmp.trust = id;

crypto/x509/x509_trs.c:103:5: 
  101.       if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
  102.           return id - X509_TRUST_MIN;
  103. >     tmp.trust = id;
  104.       if (!trtable)
  105.           return -1;

crypto/x509/x509_trs.c:104:10: Taking false branch
  102.           return id - X509_TRUST_MIN;
  103.       tmp.trust = id;
  104.       if (!trtable)
                  ^
  105.           return -1;
  106.       idx = sk_X509_TRUST_find(trtable, &tmp);

crypto/x509/x509_trs.c:106:5: 
  104.       if (!trtable)
  105.           return -1;
  106. >     idx = sk_X509_TRUST_find(trtable, &tmp);
  107.       if (idx == -1)
  108.           return -1;

include/openssl/x509.h:112:1: start of procedure sk_X509_TRUST_find()
    110.   } X509_TRUST;
    111.   
    112. > DEFINE_STACK_OF(X509_TRUST)
    113.   
    114.   /* standard trust ids */

crypto/stack/stack.c:270:1: start of procedure OPENSSL_sk_find()
      268.   }
      269.   
      270. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
      271.   {
      272.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:272:5: 
      270.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
      271.   {
      272. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
      273.   }
      274.   

crypto/stack/stack.c:245:1: start of procedure internal_find()
        243.   }
        244.   
        245. > static int internal_find(OPENSSL_STACK *st, const void *data,
        246.                            int ret_val_options)
        247.   {

crypto/stack/stack.c:251:9: Taking false branch
        249.       int i;
        250.   
        251.       if (st == NULL)
                       ^
        252.           return -1;
        253.   

crypto/stack/stack.c:254:9: Taking true branch
        252.           return -1;
        253.   
        254.       if (st->comp == NULL) {
                       ^
        255.           for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)

crypto/stack/stack.c:255:14: 
        253.   
        254.       if (st->comp == NULL) {
        255. >         for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)
        257.                   return (i);

crypto/stack/stack.c:255:21: Loop condition is true. Entering loop body
        253.   
        254.       if (st->comp == NULL) {
        255.           for (i = 0; i < st->num; i++)
                                   ^
        256.               if (st->data[i] == data)
        257.                   return (i);

crypto/stack/stack.c:256:17: Taking false branch
        254.       if (st->comp == NULL) {
        255.           for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)
                               ^
        257.                   return (i);
        258.           return (-1);

crypto/stack/stack.c:255:34: 
        253.   
        254.       if (st->comp == NULL) {
        255. >         for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)
        257.                   return (i);

crypto/stack/stack.c:255:21: Loop condition is true. Entering loop body
        253.   
        254.       if (st->comp == NULL) {
        255.           for (i = 0; i < st->num; i++)
                                   ^
        256.               if (st->data[i] == data)
        257.                   return (i);

crypto/stack/stack.c:256:17: Taking true branch
        254.       if (st->comp == NULL) {
        255.           for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)
                               ^
        257.                   return (i);
        258.           return (-1);

crypto/stack/stack.c:257:17: 
        255.           for (i = 0; i < st->num; i++)
        256.               if (st->data[i] == data)
        257. >                 return (i);
        258.           return (-1);
        259.       }

crypto/stack/stack.c:268:1: return from a call to internal_find
        266.           return (-1);
        267.       return (int)((const void **)r - st->data);
        268. > }
        269.   
        270.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)

crypto/stack/stack.c:273:1: return from a call to OPENSSL_sk_find
      271.   {
      272.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
      273. > }
      274.   
      275.   int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data)

include/openssl/x509.h:112:1: return from a call to sk_X509_TRUST_find
    110.   } X509_TRUST;
    111.   
    112. > DEFINE_STACK_OF(X509_TRUST)
    113.   
    114.   /* standard trust ids */

crypto/x509/x509_trs.c:107:9: Taking false branch
  105.           return -1;
  106.       idx = sk_X509_TRUST_find(trtable, &tmp);
  107.       if (idx == -1)
                 ^
  108.           return -1;
  109.       return idx + X509_TRUST_COUNT;

crypto/x509/x509_trs.c:109:5: 
  107.       if (idx == -1)
  108.           return -1;
  109. >     return idx + X509_TRUST_COUNT;
  110.   }
  111.   

crypto/x509/x509_trs.c:110:1: return from a call to X509_TRUST_get_by_id
  108.           return -1;
  109.       return idx + X509_TRUST_COUNT;
  110. > }
  111.   
  112.   int X509_TRUST_set(int *t, int trust)

crypto/x509/x509_trs.c:136:9: Taking false branch
134.       idx = X509_TRUST_get_by_id(id);
135.       /* Need a new entry */
136.       if (idx == -1) {
               ^
137.           if ((trtmp = OPENSSL_malloc(sizeof(*trtmp))) == NULL) {
138.               X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);

crypto/x509/x509_trs.c:143:9: 
141.           trtmp->flags = X509_TRUST_DYNAMIC;
142.       } else
143. >         trtmp = X509_TRUST_get0(idx);
144.   
145.       /* OPENSSL_free existing name if dynamic */

crypto/x509/x509_trs.c:88:1: start of procedure X509_TRUST_get0()
  86.   }
  87.   
  88. > X509_TRUST *X509_TRUST_get0(int idx)
  89.   {
  90.       if (idx < 0)

crypto/x509/x509_trs.c:90:9: Taking true branch
  88.   X509_TRUST *X509_TRUST_get0(int idx)
  89.   {
  90.       if (idx < 0)
                ^
  91.           return NULL;
  92.       if (idx < (int)X509_TRUST_COUNT)

crypto/x509/x509_trs.c:91:9: 
  89.   {
  90.       if (idx < 0)
  91. >         return NULL;
  92.       if (idx < (int)X509_TRUST_COUNT)
  93.           return trstandard + idx;

crypto/x509/x509_trs.c:95:1: return from a call to X509_TRUST_get0
  93.           return trstandard + idx;
  94.       return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);
  95. > }
  96.   
  97.   int X509_TRUST_get_by_id(int id)

crypto/x509/x509_trs.c:146:9: 
144.   
145.       /* OPENSSL_free existing name if dynamic */
146. >     if (trtmp->flags & X509_TRUST_DYNAMIC_NAME)
147.           OPENSSL_free(trtmp->name);
148.       /* dup supplied name */
