ANSI C, and OpenSSL's malloc wrapper do this, also.
Reviewed-by: Richard Levitte <levitte@openssl.org>
if ((a->length < (w + 1)) || (a->data == NULL)) {
if (!value)
return (1); /* Don't need to set */
- if (a->data == NULL)
- c = OPENSSL_malloc(w + 1);
- else
- c = OPENSSL_realloc_clean(a->data, a->length, w + 1);
+ c = OPENSSL_realloc_clean(a->data, a->length, w + 1);
if (c == NULL) {
ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
return 0;
}
if ((str->length < len) || (str->data == NULL)) {
c = str->data;
- if (c == NULL)
- str->data = OPENSSL_malloc(len + 1);
- else
- str->data = OPENSSL_realloc(c, len + 1);
-
+ str->data = OPENSSL_realloc(c, len + 1);
if (str->data == NULL) {
ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
str->data = c;
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = OPENSSL_malloc((unsigned int)num + i * 2);
- else
- sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
+ sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
if (s != NULL)
}
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)
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = OPENSSL_malloc((unsigned int)num + i * 2);
- else
- sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
+ sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
if (s != NULL)
break;
nl = strlen(h) + strlen(s) + 2;
p = *addr;
- if (p) {
+ if (p)
*p = '\0';
- p = OPENSSL_realloc(p, nl);
- } else {
- p = OPENSSL_malloc(nl);
- }
+ p = OPENSSL_realloc(p, nl);
if (p == NULL) {
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
return 0;
}
n = (len + 3) / 3 * 4;
- if (str->data == NULL)
- ret = OPENSSL_malloc(n);
- else
- ret = OPENSSL_realloc(str->data, n);
+ ret = OPENSSL_realloc(str->data, n);
if (ret == NULL) {
BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE);
len = 0;
return 0;
}
n = (len + 3) / 3 * 4;
- if (str->data == NULL)
- ret = OPENSSL_malloc(n);
- else
- ret = OPENSSL_realloc_clean(str->data, str->max, n);
+ ret = OPENSSL_realloc_clean(str->data, str->max, n);
if (ret == NULL) {
BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE);
len = 0;
if (p == NULL) {
OPENSSL_free(str);
return;
- } else
- str = p;
+ }
+ str = p;
}
BUF_strlcat(str, a, (size_t)s + 1);
}