alaurie / rpms / plymouth

Forked from rpms/plymouth 4 days ago
Clone

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

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