[openssl] master update

Matt Caswell matt at openssl.org
Mon Jan 20 14:46:33 UTC 2020


The branch master has been updated
       via  2dd04ca881414779e847a21e6be4e428257c25f1 (commit)
      from  bddbfae1cd667f0c1458deff98cbc03171e90d5a (commit)


- Log -----------------------------------------------------------------
commit 2dd04ca881414779e847a21e6be4e428257c25f1
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Jan 15 18:10:03 2020 +0000

    Fix init_thread_stop
    
    init_thread_stop maintains a linked lists of handlers that it should
    call when a thread finishes. The linked list handling wasn't quite right
    resulting in corrupted data.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    Reviewed-by: Shane Lontis <shane.lontis at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/10863)

-----------------------------------------------------------------------

Summary of changes:
 crypto/initthread.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/crypto/initthread.c b/crypto/initthread.c
index a5f770e200..d6f7869b1b 100644
--- a/crypto/initthread.c
+++ b/crypto/initthread.c
@@ -297,7 +297,7 @@ void ossl_ctx_thread_stop(void *arg)
 
 static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
 {
-    THREAD_EVENT_HANDLER *curr, *prev = NULL;
+    THREAD_EVENT_HANDLER *curr, *prev = NULL, *tmp;
 
     /* Can't do much about this */
     if (hands == NULL)
@@ -306,15 +306,20 @@ static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
     curr = *hands;
     while (curr != NULL) {
         if (arg != NULL && curr->arg != arg) {
+            prev = curr;
             curr = curr->next;
             continue;
         }
         curr->handfn(curr->arg);
-        prev = curr;
+        if (prev == NULL)
+            *hands = curr->next;
+        else
+            prev->next = curr->next;
+
+        tmp = curr;
         curr = curr->next;
-        if (prev == *hands)
-            *hands = curr;
-        OPENSSL_free(prev);
+
+        OPENSSL_free(tmp);
     }
 }
 


More information about the openssl-commits mailing list