Avoid using a dangling pointer when removing the last item
[openssl.git] / crypto / err / err.c
index e487e980cb94cf861423de11cf342b5c4f0c729c..9f81768ecc37a96671a31ffd9423a7527c2bbcdd 100644 (file)
@@ -399,8 +399,10 @@ static void int_thread_del_item(const ERR_STATE *d)
         if (int_thread_hash_references == 1
             && int_thread_hash
             && lh_ERR_STATE_num_items(int_thread_hash) == 0) {
+            int_thread_hash_references = 0;
             lh_ERR_STATE_free(int_thread_hash);
             int_thread_hash = NULL;
+            hash = NULL;
         }
     }
     CRYPTO_w_unlock(CRYPTO_LOCK_ERR);