Commit 4044ebfe authored by knekritz's avatar knekritz Committed by Rich Salz
Browse files

Avoid unconditional store in CRYPTO_malloc.



Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5372)
(cherry picked from commit 41aede86)
parent 9d927ddf
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -78,7 +78,14 @@ void *CRYPTO_malloc(size_t num, const char *file, int line)
    if (num == 0)
        return NULL;

    if (allow_customize) {
        /*
         * Disallow customization after the first allocation. We only set this
         * if necessary to avoid a store to the same cache line on every
         * allocation.
         */
        allow_customize = 0;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);
@@ -117,7 +124,6 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
        return NULL;
    }

    allow_customize = 0;
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        void *ret;