In realloc, don't destroy the old memory area if a new one couldn't be
allocated. Notified by Daniel Lucq <daniel@lucq.org>
This commit is contained in:
parent
c9d3957986
commit
ede7c28eb7
10
crypto/mem.c
10
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);
|
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||||
ret=malloc_ex_func(num,file,line);
|
ret=malloc_ex_func(num,file,line);
|
||||||
if(ret)
|
if(ret)
|
||||||
|
{
|
||||||
memcpy(ret,str,old_len);
|
memcpy(ret,str,old_len);
|
||||||
OPENSSL_cleanse(str,old_len);
|
OPENSSL_cleanse(str,old_len);
|
||||||
free_func(str);
|
free_func(str);
|
||||||
|
}
|
||||||
#ifdef LEVITTE_DEBUG_MEM
|
#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
|
#endif
|
||||||
if (realloc_debug_func != NULL)
|
if (realloc_debug_func != NULL)
|
||||||
realloc_debug_func(str, ret, num, file, line, 1);
|
realloc_debug_func(str, ret, num, file, line, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user