diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2018-05-13 13:49:05 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2018-05-13 13:49:05 +0000 |
commit | b3a8eb848af5f5193b9545b57d5a42ed3ee1d88c (patch) | |
tree | 73cb12ed5137d5097fa8981c45ba024462d4ac19 /lib/libcrypto | |
parent | da95a920f88e84e199046ae61fb257b87d10c148 (diff) |
Turn CRYPTO_realloc_clean() into a recallocarray() wrapper.
ok beck@ tb@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/malloc-wrapper.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/libcrypto/malloc-wrapper.c b/lib/libcrypto/malloc-wrapper.c index 12867387bf7..cb9a31186dd 100644 --- a/lib/libcrypto/malloc-wrapper.c +++ b/lib/libcrypto/malloc-wrapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc-wrapper.c,v 1.6 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: malloc-wrapper.c,v 1.7 2018/05/13 13:49:04 jsing Exp $ */ /* * Copyright (c) 2014 Bob Beck * @@ -148,7 +148,6 @@ CRYPTO_realloc(void *ptr, int num, const char *file, int line) { if (num <= 0) return NULL; - return realloc(ptr, num); } @@ -156,18 +155,12 @@ void * CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file, int line) { - void *ret = NULL; - if (num <= 0) return NULL; + /* Original does not support shrinking. */ if (num < old_len) - return NULL; /* original does not support shrinking */ - ret = malloc(num); - if (ret && ptr && old_len > 0) { - memcpy(ret, ptr, old_len); - freezero(ptr, old_len); - } - return ret; + return NULL; + return recallocarray(ptr, old_len, num, 1); } void |