ssl/s3_enc.c:563: error: USE_AFTER_FREE
  call to `EVP_DigestInit_ex()` eventually accesses memory that was invalidated by call to `free()` on line 563 indirectly during the call to `EVP_DigestInit_ex()`.
Showing all 18 steps of the trace


ssl/s3_enc.c:551:23: invalidation part of the trace starts here
549.       };
550.       unsigned char buf[EVP_MAX_MD_SIZE];
551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                             ^
552.       int i, ret = 0;
553.       unsigned int n;

ssl/s3_enc.c:551:23: passed as argument to `EVP_MD_CTX_new`
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                               ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:551:23: return from call to `EVP_MD_CTX_new`
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                               ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:551:5: assigned
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
             ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:563:13: when calling `EVP_DigestInit_ex` here
  561.       }
  562.       for (i = 0; i < 3; i++) {
  563.           if (EVP_DigestInit_ex(ctx, s->ctx->sha1, NULL) <= 0
                     ^
  564.                   || EVP_DigestUpdate(ctx, salt[i],
  565.                                       strlen((const char *)salt[i])) <= 0

crypto/evp/digest.c:169:1: parameter `ctx` of EVP_DigestInit_ex
    167.   }
    168.   
    169. > int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
    170.   {
    171.       EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);

crypto/evp/digest.c:228:13: when calling `CRYPTO_free` here
    226.       if (ctx->digest != type) {
    227.           if (ctx->digest && ctx->digest->ctx_size)
    228.               OPENSSL_free(ctx->md_data);
                       ^
    229.           ctx->digest = type;
    230.           if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size) {

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

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

ssl/s3_enc.c:551:23: use-after-lifetime part of the trace starts here
549.       };
550.       unsigned char buf[EVP_MAX_MD_SIZE];
551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                             ^
552.       int i, ret = 0;
553.       unsigned int n;

ssl/s3_enc.c:551:23: passed as argument to `EVP_MD_CTX_new`
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                               ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:551:23: return from call to `EVP_MD_CTX_new`
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
                               ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:551:5: assigned
  549.       };
  550.       unsigned char buf[EVP_MAX_MD_SIZE];
  551.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
             ^
  552.       int i, ret = 0;
  553.       unsigned int n;

ssl/s3_enc.c:563:13: when calling `EVP_DigestInit_ex` here
  561.       }
  562.       for (i = 0; i < 3; i++) {
  563.           if (EVP_DigestInit_ex(ctx, s->ctx->sha1, NULL) <= 0
                     ^
  564.                   || EVP_DigestUpdate(ctx, salt[i],
  565.                                       strlen((const char *)salt[i])) <= 0

crypto/evp/digest.c:169:1: parameter `ctx` of EVP_DigestInit_ex
    167.   }
    168.   
    169. > int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
    170.   {
    171.       EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);

crypto/evp/digest.c:228:13: when calling `CRYPTO_free` here
    226.       if (ctx->digest != type) {
    227.           if (ctx->digest && ctx->digest->ctx_size)
    228.               OPENSSL_free(ctx->md_data);
                       ^
    229.           ctx->digest = type;
    230.           if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size) {

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

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