summaryrefslogtreecommitdiffstats
path: root/crypto/mem.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2003-10-07 12:09:39 +0000
committerRichard Levitte <levitte@openssl.org>2003-10-07 12:09:39 +0000
commit83eb412da88a1e0b633511a7d07d7f40356dbe6a (patch)
tree9ec33bc95fc4271e65587fec88a9d5cadb18ff52 /crypto/mem.c
parent4d1c443123acbbb8a4890605937c1aa199c7f01d (diff)
In realloc, don't destroy the old memory area if a new one couldn't be
allocated. Notified by Daniel Lucq <daniel@lucq.org>
Diffstat (limited to 'crypto/mem.c')
-rw-r--r--crypto/mem.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/mem.c b/crypto/mem.c
index 57f295877d..d01924c268 100644
--- a/crypto/mem.c
+++ b/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);