[Spice-devel] [PATCH phodav 05/13] spice: clear loop pointer on unref
Jakub Janků
jjanku at redhat.com
Thu May 23 08:37:17 UTC 2019
The pointer to loop must be set to NULL on unref.
Quit signal handler can be called at any time,
using g_main_loop_quit() on a freed loop could lead to segfault.
Signed-off-by: Jakub Janků <jjanku at redhat.com>
---
spice/spice-webdavd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 6ad63c5..3fac28b 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -243,7 +243,8 @@ quit (int sig)
if (sig == SIGINT || sig == SIGTERM)
quit_service = TRUE;
- g_main_loop_quit (loop);
+ if (loop)
+ g_main_loop_quit (loop);
}
static Client *
@@ -982,7 +983,7 @@ run_service (ServiceData *service_data)
start_mux_read (mux_istream);
g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ g_clear_pointer (&loop, g_main_loop_unref);
#ifdef G_OS_WIN32
g_cancellable_cancel (map_drive_data.cancel_map);
--
2.21.0
More information about the Spice-devel
mailing list