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

87 lines
2.7 KiB
Diff
Raw Normal View History

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