[openssl-commits] [openssl] master update
Rich Salz
rsalz at openssl.org
Tue Apr 28 20:35:09 UTC 2015
The branch master has been updated
via 2d29e2df0c9040e139d68c8659ee0342a6ac3dd1 (commit)
from b196e7d936fb377d9c5b305748ac25ff0e53ef6d (commit)
- Log -----------------------------------------------------------------
commit 2d29e2df0c9040e139d68c8659ee0342a6ac3dd1
Author: Rich Salz <rsalz at openssl.org>
Date: Tue Apr 28 16:34:52 2015 -0400
realloc of NULL is like malloc
ANSI C, and OpenSSL's malloc wrapper do this, also.
Reviewed-by: Richard Levitte <levitte at openssl.org>
-----------------------------------------------------------------------
Summary of changes:
crypto/asn1/a_bitstr.c | 5 +----
crypto/asn1/asn1_lib.c | 6 +-----
crypto/asn1/f_enum.c | 5 +----
crypto/asn1/f_int.c | 5 +----
crypto/asn1/f_string.c | 5 +----
crypto/bio/b_sock.c | 7 ++-----
crypto/buffer/buffer.c | 10 ++--------
crypto/err/err.c | 4 ++--
8 files changed, 11 insertions(+), 36 deletions(-)
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index 8a9e17c..ba243f1 100644
--- a/crypto/asn1/a_bitstr.c
+++ b/crypto/asn1/a_bitstr.c
@@ -205,10 +205,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
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;
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 97f1d23..a892d7f 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -317,11 +317,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
}
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;
diff --git a/crypto/asn1/f_enum.c b/crypto/asn1/f_enum.c
index c623cdc..2ec99a5 100644
--- a/crypto/asn1/f_enum.c
+++ b/crypto/asn1/f_enum.c
@@ -151,10 +151,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *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(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)
diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c
index 39c9a61..f74252c 100644
--- a/crypto/asn1/f_int.c
+++ b/crypto/asn1/f_int.c
@@ -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)
diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c
index 6cb4cfd..53f8cf3 100644
--- a/crypto/asn1/f_string.c
+++ b/crypto/asn1/f_string.c
@@ -157,10 +157,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *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(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)
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index ca485d9..a4fded5 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -673,12 +673,9 @@ int BIO_accept(int sock, char **addr)
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;
diff --git a/crypto/buffer/buffer.c b/crypto/buffer/buffer.c
index 0859974..c77fdc5 100644
--- a/crypto/buffer/buffer.c
+++ b/crypto/buffer/buffer.c
@@ -114,10 +114,7 @@ size_t BUF_MEM_grow(BUF_MEM *str, size_t len)
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;
@@ -151,10 +148,7 @@ size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
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;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 4752148..ec7da22 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -969,8 +969,8 @@ void ERR_add_error_vdata(int num, va_list args)
if (p == NULL) {
OPENSSL_free(str);
return;
- } else
- str = p;
+ }
+ str = p;
}
BUF_strlcat(str, a, (size_t)s + 1);
}
More information about the openssl-commits
mailing list