diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2003-10-25 12:41:03 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2003-10-25 12:41:03 +0000 |
commit | 9b1c2ad0d5df27b0a8cd3b342885fa8b4c4a4c58 (patch) | |
tree | 7cf7c47eec59e557593be3971962f321c6782557 | |
parent | 90da90c4c2e2819ff08635c7ab264deaf50a5e77 (diff) |
don't destroy old pointer if realloc fails; from Daniel Lucq; ok deraadt@
-rw-r--r-- | lib/libssl/src/crypto/mem.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libssl/src/crypto/mem.c b/lib/libssl/src/crypto/mem.c index 29df7d35b24..bb862db4997 100644 --- a/lib/libssl/src/crypto/mem.c +++ b/lib/libssl/src/crypto/mem.c @@ -352,11 +352,15 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); if(ret) + { memcpy(ret,str,old_len); - OPENSSL_cleanse(str,old_len); - free_func(str); + OPENSSL_cleanse(str,old_len); + free_func(str); + } #ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num); + fprintf(stderr, + "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", + str, ret, num); #endif if (realloc_debug_func != NULL) realloc_debug_func(str, ret, num, file, line, 1); |