Fix coverity CID #1454815 - NULL ptr dereference in initthread.c
authorShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 02:52:56 +0000 (12:52 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Sat, 5 Sep 2020 05:41:31 +0000 (15:41 +1000)
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12708)

crypto/initthread.c

index c9a34a77db2c730313998847e15bfcd463b53715..5ad38dfee2f0b918d3c3d87da8c29006bb481e8b 100644 (file)
@@ -392,13 +392,14 @@ static int init_thread_deregister(void *index, int all)
     for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) {
         THREAD_EVENT_HANDLER **hands
             = sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i);
-        THREAD_EVENT_HANDLER *curr = *hands, *prev = NULL, *tmp;
+        THREAD_EVENT_HANDLER *curr = NULL, *prev = NULL, *tmp;
 
         if (hands == NULL) {
             if (!all)
                 CRYPTO_THREAD_unlock(gtr->lock);
             return 0;
         }
+        curr = *hands;
         while (curr != NULL) {
             if (all || curr->index == index) {
                 if (prev != NULL)