crypto/stack/stack.c:59: error: USE_AFTER_FREE
  call to `OPENSSL_sk_free()` eventually accesses memory that was invalidated by call to `free()` on line 46 indirectly during the call to `CRYPTO_realloc()`.
Showing all 14 steps of the trace


crypto/stack/stack.c:44:10: invalidation part of the trace starts here
42.       char **s;
43.   
44.       if ((ret = OPENSSL_sk_new(sk->comp)) == NULL)
               ^
45.           goto err;
46.       s = OPENSSL_realloc((char *)ret->data,

crypto/stack/stack.c:44:10: assigned
  42.       char **s;
  43.   
  44.       if ((ret = OPENSSL_sk_new(sk->comp)) == NULL)
                 ^
  45.           goto err;
  46.       s = OPENSSL_realloc((char *)ret->data,

crypto/stack/stack.c:46:9: when calling `CRYPTO_realloc` here
  44.       if ((ret = OPENSSL_sk_new(sk->comp)) == NULL)
  45.           goto err;
  46.       s = OPENSSL_realloc((char *)ret->data,
                ^
  47.                           (unsigned int)sizeof(char *) * sk->num_alloc);
  48.       if (s == NULL)

crypto/mem.c:107:1: parameter `str` of CRYPTO_realloc
    105.   }
    106.   
    107. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
    108.   {
    109.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)

crypto/mem.c:116:9: when calling `CRYPTO_free` here
    114.   
    115.       if (num == 0) {
    116.           CRYPTO_free(str, file, line);
                   ^
    117.           return NULL;
    118.       }

crypto/mem.c:163:1: parameter `str` of CRYPTO_free
      161.   }
      162.   
      163. > void CRYPTO_free(void *str, const char *file, int line)
      164.   {
      165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:179:5: was invalidated by call to `free()`
      177.       }
      178.   #else
      179.       free(str);
                 ^
      180.   #endif
      181.   }

crypto/stack/stack.c:44:10: use-after-lifetime part of the trace starts here
42.       char **s;
43.   
44.       if ((ret = OPENSSL_sk_new(sk->comp)) == NULL)
               ^
45.           goto err;
46.       s = OPENSSL_realloc((char *)ret->data,

crypto/stack/stack.c:44:10: assigned
  42.       char **s;
  43.   
  44.       if ((ret = OPENSSL_sk_new(sk->comp)) == NULL)
                 ^
  45.           goto err;
  46.       s = OPENSSL_realloc((char *)ret->data,

crypto/stack/stack.c:59:5: when calling `OPENSSL_sk_free` here
  57.       return (ret);
  58.    err:
  59.       OPENSSL_sk_free(ret);
            ^
  60.       return (NULL);
  61.   }

crypto/stack/stack.c:262:1: parameter `st` of OPENSSL_sk_free
    260.   }
    261.   
    262. > void OPENSSL_sk_free(OPENSSL_STACK *st)
    263.   {
    264.       if (st == NULL)

crypto/stack/stack.c:266:5: when calling `CRYPTO_free` here
    264.       if (st == NULL)
    265.           return;
    266.       OPENSSL_free(st->data);
               ^
    267.       OPENSSL_free(st);
    268.   }

crypto/mem.c:163:1: parameter `str` of CRYPTO_free
      161.   }
      162.   
      163. > void CRYPTO_free(void *str, const char *file, int line)
      164.   {
      165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:179:5: invalid access occurs here
      177.       }
      178.   #else
      179.       free(str);
                 ^
      180.   #endif
      181.   }
