apps/engine.c:68: error: USE_AFTER_FREE
  call to `CRYPTO_free()` eventually accesses memory that was invalidated by call to `free()` on line 66 indirectly during the call to `CRYPTO_realloc()`.
Showing all 13 steps of the trace


apps/engine.c:49:1: invalidation part of the trace starts here
47.   };
48.   
49. > static int append_buf(char **buf, int *size, const char *s)
50.   {
51.       const int expand = 256;

apps/engine.c:49:1: parameter `buf` of append_buf
  47.   };
  48.   
  49. > static int append_buf(char **buf, int *size, const char *s)
  50.   {
  51.       const int expand = 256;

apps/engine.c:53:5: assigned
  51.       const int expand = 256;
  52.       int len = strlen(s) + 1;
  53.       char *p = *buf;
            ^
  54.   
  55.       if (p == NULL) {

apps/engine.c:66:17: when calling `CRYPTO_realloc` here
  64.           if (len > *size) {
  65.               *size = ((len + expand - 1) / expand) * expand;
  66.               p = OPENSSL_realloc(p, *size);
                        ^
  67.               if (p == NULL) {
  68.                   OPENSSL_free(*buf);

crypto/mem.c:228:1: parameter `str` of CRYPTO_realloc
    226.   }
    227.   
    228. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
    229.   {
    230.       INCREMENT(realloc_count);

crypto/mem.c:239:9: when calling `CRYPTO_free` here
    237.   
    238.       if (num == 0) {
    239.           CRYPTO_free(str, file, line);
                   ^
    240.           return NULL;
    241.       }

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
      284.   }
      285.   
      286. > void CRYPTO_free(void *str, const char *file, int line)
      287.   {
      288.       INCREMENT(free_count);

crypto/mem.c:303:5: was invalidated by call to `free()`
      301.       }
      302.   #else
      303.       free(str);
                 ^
      304.   #endif
      305.   }

apps/engine.c:49:1: use-after-lifetime part of the trace starts here
47.   };
48.   
49. > static int append_buf(char **buf, int *size, const char *s)
50.   {
51.       const int expand = 256;

apps/engine.c:49:1: parameter `buf` of append_buf
  47.   };
  48.   
  49. > static int append_buf(char **buf, int *size, const char *s)
  50.   {
  51.       const int expand = 256;

apps/engine.c:68:17: when calling `CRYPTO_free` here
  66.               p = OPENSSL_realloc(p, *size);
  67.               if (p == NULL) {
  68.                   OPENSSL_free(*buf);
                        ^
  69.                   *buf = NULL;
  70.                   return 0;

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
    284.   }
    285.   
    286. > void CRYPTO_free(void *str, const char *file, int line)
    287.   {
    288.       INCREMENT(free_count);

crypto/mem.c:303:5: invalid access occurs here
    301.       }
    302.   #else
    303.       free(str);
               ^
    304.   #endif
    305.   }
