diff options
author | Richard Levitte <levitte@openssl.org> | 2003-10-06 11:09:44 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2003-10-06 11:09:44 +0200 |
commit | c40b9bdefb59be7e640cd7a10bfd2fa26ea1fe7b (patch) | |
tree | 9264f58ab5c0cbe3824adc5c8ecc3883ddb1e83f /crypto/comp | |
parent | Remove unused code, don't use zlib functions that are really macros (diff) | |
download | openssl-c40b9bdefb59be7e640cd7a10bfd2fa26ea1fe7b.tar.xz openssl-c40b9bdefb59be7e640cd7a10bfd2fa26ea1fe7b.zip |
Setting the ex_data index is unsafe in a threaded environment, so
let's wrap it with a lock.
Diffstat (limited to 'crypto/comp')
-rw-r--r-- | crypto/comp/c_zlib.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index c3167fcead..7553a2d107 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -178,9 +178,12 @@ static int zlib_stateful_init(COMP_CTX *ctx) CRYPTO_new_ex_data(CRYPTO_EX_INDEX_COMP,ctx,&ctx->ex_data); if (zlib_stateful_ex_idx == -1) { - zlib_stateful_ex_idx = - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP, - 0,NULL,NULL,NULL,zlib_stateful_free_ex_data); + CRYPTO_w_lock(CRYPTO_LOCK_COMP); + if (zlib_stateful_ex_idx == -1) + zlib_stateful_ex_idx = + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP, + 0,NULL,NULL,NULL,zlib_stateful_free_ex_data); + CRYPTO_w_unlock(CRYPTO_LOCK_COMP); if (zlib_stateful_ex_idx == -1) goto err; } |