Fix crash in BUF_MEM_grow_clean.
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 9 Jul 2017 19:22:26 +0000 (21:22 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 10 Jul 2017 14:25:43 +0000 (16:25 +0200)
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/3896)

crypto/buffer/buffer.c

index 6b0bd4a40429f3816aa05118ed3b6c0fda1afff8..ad7128a732a9ac4b7930951e1beeb0a5125a0f77 100644 (file)
@@ -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);
 }