summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-07-25 16:56:39 +0000
committerRichard Levitte <levitte@openssl.org>2000-07-25 16:56:39 +0000
commit34f0fe9de0597bd933f2dd13ae26843ed5273922 (patch)
tree8a0c61091b8384a2e92d26e39a069531d3f81dce /crypto/err
parentccb9aae90550fced1412074998927813903854bd (diff)
Avoid a race condition if another thread happens to remove the error
state at the same time.
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index ad062a9022..7ce9e8fb9a 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -652,12 +652,15 @@ void ERR_remove_state(unsigned long pid)
pid=(unsigned long)CRYPTO_thread_id();
tmp.pid=pid;
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
- p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
- if (lh_num_items(thread_hash) == 0)
+ if (thread_hash)
{
- /* make sure we don't leak memory */
- lh_free(thread_hash);
- thread_hash = NULL;
+ p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
+ if (lh_num_items(thread_hash) == 0)
+ {
+ /* make sure we don't leak memory */
+ lh_free(thread_hash);
+ thread_hash = NULL;
+ }
}
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);