Commit 2ac7753c authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Fix CRYPTO_clear_realloc() bug.



If allocation in CRYPTO_clear_realloc() fails don't free up the original
buffer: this is consistent with the behaviour of realloc(3) and is expected
in other places in OpenSSL.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarViktor Dukhovni <viktor@openssl.org>
parent e38bd948
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -201,9 +201,10 @@ void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,
    }

    ret = CRYPTO_malloc(num, file, line);
    if (ret)
    if (ret != NULL) {
        memcpy(ret, str, old_len);
        CRYPTO_clear_free(str, old_len, file, line);
    }
    return ret;
}