]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix memory leak in engine_cleanup_add_first()
authorKovalev Vasiliy <minskij10@yandex.ru>
Thu, 4 May 2023 12:12:33 +0000 (16:12 +0400)
committerTomas Mraz <tomas@openssl.org>
Tue, 9 May 2023 15:31:43 +0000 (17:31 +0200)
Fixes #20870

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20880)

crypto/engine/eng_lib.c

index 40e0413a265ed5dc826a7874478c8415b9ac6591..b10751336fac927f1511be85efabc08116eb5831 100644 (file)
@@ -140,8 +140,9 @@ void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb)
     if (!int_cleanup_check(1))
         return;
     item = int_cleanup_item(cb);
-    if (item)
-        sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0);
+    if (item != NULL)
+        if (sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0) <= 0)
+            OPENSSL_free(item);
 }
 
 void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)