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


crypto/evp/evp_enc.c:104:1: invalidation part of the trace starts here
102.   }
103.   
104. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
105.                      const unsigned char *key, const unsigned char *iv, int enc)
106.   {

crypto/evp/evp_enc.c:104:1: parameter `ctx` of EVP_CipherInit
  102.   }
  103.   
  104. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  105.                      const unsigned char *key, const unsigned char *iv, int enc)
  106.   {

crypto/evp/evp_enc.c:107:5: when calling `EVP_CIPHER_CTX_reset` here
  105.                      const unsigned char *key, const unsigned char *iv, int enc)
  106.   {
  107.       EVP_CIPHER_CTX_reset(ctx);
             ^
  108.       return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
  109.   }

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

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

crypto/mem.c:234:1: parameter `str` of CRYPTO_free
      232.   }
      233.   
      234. > void CRYPTO_free(void *str)
      235.   {
      236.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:245:5: was invalidated by call to `free()`
      243.       }
      244.   #else
      245.       free(str);
                 ^
      246.   #endif
      247.   }

crypto/evp/evp_enc.c:104:1: use-after-lifetime part of the trace starts here
102.   }
103.   
104. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
105.                      const unsigned char *key, const unsigned char *iv, int enc)
106.   {

crypto/evp/evp_enc.c:104:1: parameter `ctx` of EVP_CipherInit
  102.   }
  103.   
  104. > int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  105.                      const unsigned char *key, const unsigned char *iv, int enc)
  106.   {

crypto/evp/evp_enc.c:108:12: when calling `EVP_CipherInit_ex` here
  106.   {
  107.       EVP_CIPHER_CTX_reset(ctx);
  108.       return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
                    ^
  109.   }
  110.   

crypto/mem.c:234:1: parameter `str` of CRYPTO_free
    232.   }
    233.   
    234. > void CRYPTO_free(void *str)
    235.   {
    236.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:245:5: invalid access occurs here
    243.       }
    244.   #else
    245.       free(str);
               ^
    246.   #endif
    247.   }

void CRYPTO_free(void *str)
{
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0);
        free(str);
        CRYPTO_mem_debug_free(str, 1);
    } 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    if (c->engine)\n        ENGINE_finish(c->engine);\n#endif\n    memset(c, 0, sizeof(*c));\n    return 1;\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']