Blame SOURCES/0003-event-loop-fix-leak-in-error-path.patch

ff210d
From 9f335750af9e46d6597de0cea5b8a2f7db951dc1 Mon Sep 17 00:00:00 2001
ff210d
From: Ray Strode <rstrode@redhat.com>
ff210d
Date: Mon, 15 Oct 2018 21:07:01 -0400
ff210d
Subject: [PATCH 3/6] event-loop: fix leak in error path
ff210d
ff210d
ply_event_loop_new fails to clean itself up if it's unable to
ff210d
create a pipe for dispatching signals.
ff210d
ff210d
This commit fixes that.
ff210d
---
ff210d
 src/libply/ply-event-loop.c | 4 +++-
ff210d
 1 file changed, 3 insertions(+), 1 deletion(-)
ff210d
ff210d
diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c
ff210d
index 9736dae..0e8ad7c 100644
ff210d
--- a/src/libply/ply-event-loop.c
ff210d
+++ b/src/libply/ply-event-loop.c
ff210d
@@ -469,62 +469,64 @@ ply_event_loop_remove_destination_by_fd_watch (ply_event_loop_t *loop,
ff210d
         source = destination->source;
ff210d
         assert (source != NULL);
ff210d
 
ff210d
         ply_list_remove_data (source->destinations, destination);
ff210d
         ply_event_source_drop_reference (source);
ff210d
         assert (ply_list_find_node (source->destinations, destination) == NULL);
ff210d
         ply_event_loop_update_source_event_mask (loop, source);
ff210d
 }
ff210d
 
ff210d
 ply_event_loop_t *
ff210d
 ply_event_loop_new (void)
ff210d
 {
ff210d
         ply_event_loop_t *loop;
ff210d
 
ff210d
         loop = calloc (1, sizeof(ply_event_loop_t));
ff210d
 
ff210d
         loop->epoll_fd = epoll_create1 (EPOLL_CLOEXEC);
ff210d
         loop->wakeup_time = PLY_EVENT_LOOP_NO_TIMED_WAKEUP;
ff210d
 
ff210d
         assert (loop->epoll_fd >= 0);
ff210d
 
ff210d
         loop->should_exit = false;
ff210d
         loop->exit_code = 0;
ff210d
 
ff210d
         loop->sources = ply_list_new ();
ff210d
         loop->exit_closures = ply_list_new ();
ff210d
         loop->timeout_watches = ply_list_new ();
ff210d
 
ff210d
         loop->signal_dispatcher = ply_signal_dispatcher_new ();
ff210d
 
ff210d
-        if (loop->signal_dispatcher == NULL)
ff210d
+        if (loop->signal_dispatcher == NULL) {
ff210d
+                ply_event_loop_free (loop);
ff210d
                 return NULL;
ff210d
+        }
ff210d
 
ff210d
         ply_event_loop_watch_fd (loop,
ff210d
                                  ply_signal_dispatcher_receiver_fd,
ff210d
                                  PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
ff210d
                                  (ply_event_handler_t)
ff210d
                                  ply_signal_dispatcher_dispatch_signal,
ff210d
                                  (ply_event_handler_t)
ff210d
                                  ply_signal_dispatcher_reset_signal_sources,
ff210d
                                  loop->signal_dispatcher);
ff210d
 
ff210d
         return loop;
ff210d
 }
ff210d
 
ff210d
 ply_event_loop_t *
ff210d
 ply_event_loop_get_default (void)
ff210d
 {
ff210d
         static ply_event_loop_t *loop = NULL;
ff210d
 
ff210d
         if (loop == NULL)
ff210d
                 loop = ply_event_loop_new ();
ff210d
 
ff210d
         return loop;
ff210d
 }
ff210d
 
ff210d
 static void
ff210d
 ply_event_loop_free_exit_closures (ply_event_loop_t *loop)
ff210d
 {
ff210d
         ply_list_node_t *node;
ff210d
 
ff210d
         node = ply_list_get_first_node (loop->exit_closures);
ff210d
-- 
ff210d
2.17.1
ff210d