EVENT QUEUE: Fix memory leak (coverity)
authorHugo Landau <hlandau@openssl.org>
Thu, 27 Jul 2023 14:57:51 +0000 (15:57 +0100)
committerHugo Landau <hlandau@openssl.org>
Thu, 10 Aug 2023 17:19:50 +0000 (18:19 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21565)

ssl/event_queue.c

index ed3c7909047cf2318af89440777930ef3f6c4e36..f2169ec3abd00ef6e1177ad5755bad59cf7e81eb 100644 (file)
@@ -111,8 +111,11 @@ OSSL_EVENT *ossl_event_queue_add_new(OSSL_EVENT_QUEUE *queue,
 {
     OSSL_EVENT *e = OPENSSL_malloc(sizeof(*e));
 
-    if (e == NULL || queue == NULL)
+    if (e == NULL || queue == NULL) {
+        OPENSSL_free(e);
         return NULL;
+    }
+
     ossl_event_set(e, type, priority, when, ctx, payload, payload_size);
     e->flag_dynamic = 1;
     if (event_queue_add(queue, e))