realloc of NULL is like malloc

ANSI C, and OpenSSL's malloc wrapper do this, also.

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Rich Salz
2015-04-28 16:34:52 -04:00
parent b196e7d936
commit 2d29e2df0c
8 changed files with 11 additions and 36 deletions

View File

@@ -165,10 +165,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
}
i /= 2;
if (num + i > slen) {
if (s == NULL)
sp = OPENSSL_malloc((unsigned int)num + i * 2);
else
sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
if (s != NULL)