diff options
author | knekritz <knekritz@fb.com> | 2018-03-06 13:21:49 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2018-03-06 13:21:49 -0500 |
commit | 41aede863b76202347c2d5e2c2666428084f9203 (patch) | |
tree | cba088435d7bdd46cc8b8137e24ff02af3c3bb47 /crypto/mem.c | |
parent | ce3dcdc9fe11e4d262f00633a139b2ee1d2ff8a0 (diff) |
Avoid unconditional store in CRYPTO_malloc.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5372)
Diffstat (limited to 'crypto/mem.c')
-rw-r--r-- | crypto/mem.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/mem.c b/crypto/mem.c index b3f7a1fa00..336446789c 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -201,7 +201,14 @@ void *CRYPTO_malloc(size_t num, const char *file, int line) return NULL; FAILTEST(); - allow_customize = 0; + 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); @@ -243,7 +250,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; |