From e1ca9e1f6db97052a0ebea6591f323b12b1e0020 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Sun, 9 Jul 2017 21:22:26 +0200 Subject: [PATCH] Fix crash in BUF_MEM_grow_clean. Reviewed-by: Tim Hudson Reviewed-by: Ben Kaduk (Merged from https://github.com/openssl/openssl/pull/3896) --- crypto/buffer/buffer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/buffer/buffer.c b/crypto/buffer/buffer.c index 6b0bd4a404..ad7128a732 100644 --- a/crypto/buffer/buffer.c +++ b/crypto/buffer/buffer.c @@ -62,9 +62,11 @@ static char *sec_alloc_realloc(BUF_MEM *str, size_t len) ret = OPENSSL_secure_malloc(len); if (str->data != NULL) { - if (ret != NULL) + if (ret != NULL) { memcpy(ret, str->data, str->length); - OPENSSL_secure_free(str->data); + OPENSSL_secure_free(str->data); + str->data = NULL; + } } return (ret); } -- 2.25.1