crypto/evp/evp_enc.c:101: error: USE_AFTER_FREE
  call to `EVP_CipherInit_ex()` eventually accesses memory that was invalidated by call to `free()` on line 100 indirectly during the call to `EVP_CIPHER_CTX_reset()`.
Showing all 12 steps of the trace


crypto/evp/evp_enc.c:97:1: invalidation part of the trace starts here
95.   }
96.   
97. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
98.                      const unsigned char *key, const unsigned char *iv, int enc)
99.   {

crypto/evp/evp_enc.c:97:1: parameter `ctx` of EVP_CipherInit
  95.   }
  96.   
  97. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  98.                      const unsigned char *key, const unsigned char *iv, int enc)
  99.   {

crypto/evp/evp_enc.c:100:5: when calling `EVP_CIPHER_CTX_reset` here
  98.                      const unsigned char *key, const unsigned char *iv, int enc)
  99.   {
  100.       EVP_CIPHER_CTX_reset(ctx);
             ^
  101.       return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
  102.   }

crypto/evp/evp_enc.c:67:1: parameter `c` of EVP_CIPHER_CTX_reset
    65.   #include "evp_locl.h"
    66.   
    67. > int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c)
    68.   {
    69.       if (c == NULL)

crypto/evp/evp_enc.c:78:5: when calling `CRYPTO_free` here
    76.               OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
    77.       }
    78.       OPENSSL_free(c->cipher_data);
              ^
    79.   #ifndef OPENSSL_NO_ENGINE
    80.       ENGINE_finish(c->engine);

crypto/mem.c:210:1: parameter `str` of CRYPTO_free
      208.   }
      209.   
      210. > void CRYPTO_free(void *str, const char *file, int line)
      211.   {
      212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:226:5: was invalidated by call to `free()`
      224.       }
      225.   #else
      226.       free(str);
                 ^
      227.   #endif
      228.   }

crypto/evp/evp_enc.c:97:1: use-after-lifetime part of the trace starts here
95.   }
96.   
97. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
98.                      const unsigned char *key, const unsigned char *iv, int enc)
99.   {

crypto/evp/evp_enc.c:97:1: parameter `ctx` of EVP_CipherInit
  95.   }
  96.   
  97. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  98.                      const unsigned char *key, const unsigned char *iv, int enc)
  99.   {

crypto/evp/evp_enc.c:101:12: when calling `EVP_CipherInit_ex` here
  99.   {
  100.       EVP_CIPHER_CTX_reset(ctx);
  101.       return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
                    ^
  102.   }
  103.   

crypto/mem.c:210:1: parameter `str` of CRYPTO_free
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:226:5: invalid access occurs here
    224.       }
    225.   #else
    226.       free(str);
               ^
    227.   #endif
    228.   }

void CRYPTO_free(void *str, const char *file, int line)
{
    if (free_impl != NULL && free_impl != &CRYPTO_free) {
        free_impl(str, file, line);
        return;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0, file, line);
        free(str);
        CRYPTO_mem_debug_free(str, 1, file, line);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                   const unsigned char *key, const unsigned char *iv, int enc)\n{\n    EVP_CIPHER_CTX_reset(ctx);\n    return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);\n}', 'int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c)\n{\n    if (c == NULL)\n        return 1;\n    if (c->cipher != NULL) {\n        if (c->cipher->cleanup && !c->cipher->cleanup(c))\n            return 0;\n        if (c->cipher_data && c->cipher->ctx_size)\n            OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);\n    }\n    OPENSSL_free(c->cipher_data);\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(c->engine);\n#endif\n    memset(c, 0, sizeof(*c));\n    return 1;\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']