summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/mem.c')
-rw-r--r--src/lib/libcrypto/mem.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 29df7d35b2..dd86733b77 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -252,7 +252,7 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
252 void *ret = NULL; 252 void *ret = NULL;
253 extern unsigned char cleanse_ctr; 253 extern unsigned char cleanse_ctr;
254 254
255 if (num < 0) return NULL; 255 if (num <= 0) return NULL;
256 256
257 allow_customize = 0; 257 allow_customize = 0;
258 if (malloc_debug_func != NULL) 258 if (malloc_debug_func != NULL)
@@ -293,7 +293,7 @@ void *CRYPTO_malloc(int num, const char *file, int line)
293 void *ret = NULL; 293 void *ret = NULL;
294 extern unsigned char cleanse_ctr; 294 extern unsigned char cleanse_ctr;
295 295
296 if (num < 0) return NULL; 296 if (num <= 0) return NULL;
297 297
298 allow_customize = 0; 298 allow_customize = 0;
299 if (malloc_debug_func != NULL) 299 if (malloc_debug_func != NULL)
@@ -324,7 +324,7 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
324 if (str == NULL) 324 if (str == NULL)
325 return CRYPTO_malloc(num, file, line); 325 return CRYPTO_malloc(num, file, line);
326 326
327 if (num < 0) return NULL; 327 if (num <= 0) return NULL;
328 328
329 if (realloc_debug_func != NULL) 329 if (realloc_debug_func != NULL)
330 realloc_debug_func(str, NULL, num, file, line, 0); 330 realloc_debug_func(str, NULL, num, file, line, 0);
@@ -346,17 +346,21 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
346 if (str == NULL) 346 if (str == NULL)
347 return CRYPTO_malloc(num, file, line); 347 return CRYPTO_malloc(num, file, line);
348 348
349 if (num < 0) return NULL; 349 if (num <= 0) return NULL;
350 350
351 if (realloc_debug_func != NULL) 351 if (realloc_debug_func != NULL)
352 realloc_debug_func(str, NULL, num, file, line, 0); 352 realloc_debug_func(str, NULL, num, file, line, 0);
353 ret=malloc_ex_func(num,file,line); 353 ret=malloc_ex_func(num,file,line);
354 if(ret) 354 if(ret)
355 {
355 memcpy(ret,str,old_len); 356 memcpy(ret,str,old_len);
356 OPENSSL_cleanse(str,old_len); 357 OPENSSL_cleanse(str,old_len);
357 free_func(str); 358 free_func(str);
359 }
358#ifdef LEVITTE_DEBUG_MEM 360#ifdef LEVITTE_DEBUG_MEM
359 fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num); 361 fprintf(stderr,
362 "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n",
363 str, ret, num);
360#endif 364#endif
361 if (realloc_debug_func != NULL) 365 if (realloc_debug_func != NULL)
362 realloc_debug_func(str, ret, num, file, line, 1); 366 realloc_debug_func(str, ret, num, file, line, 1);