Commit 2d29e2df authored by Rich Salz's avatar Rich Salz
Browse files

realloc of NULL is like malloc



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

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent b196e7d9
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -205,9 +205,6 @@ 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);
        if (c == NULL) {
            ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
+1 −5
Original line number Diff line number Diff line
@@ -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);

        if (str->data == NULL) {
            ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
            str->data = c;
+1 −4
Original line number Diff line number Diff line
@@ -151,9 +151,6 @@ 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);
            if (sp == NULL) {
                ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
+1 −4
Original line number Diff line number Diff line
@@ -165,9 +165,6 @@ 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);
            if (sp == NULL) {
                ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
+1 −4
Original line number Diff line number Diff line
@@ -157,9 +157,6 @@ 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);
            if (sp == NULL) {
                ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
Loading