[glib: 1/3] subprocess: Fix communicate_cancelled signature



commit 5cc4cca9c6166284f4834f0c055aba806f0e0b0b
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Aug 24 06:05:03 2018 +0200

    subprocess: Fix communicate_cancelled signature
    
    The source callback for a GCancellable should have the cancellable itself
    as first argument.
    This was not the case, and when this code was hit, we were instead trying
    to treat the pointer as a CommunicateState reference and thus wrongly
    deferencing it, causing a memory error and a crash.

 gio/gsubprocess.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index 31822e59c..23bfbddf2 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -1528,7 +1528,8 @@ g_subprocess_communicate_made_progress (GObject      *source_object,
 }
 
 static gboolean
-g_subprocess_communicate_cancelled (gpointer user_data)
+g_subprocess_communicate_cancelled (GCancellable *cancellable,
+                                    gpointer      user_data)
 {
   CommunicateState *state = user_data;
 
@@ -1580,7 +1581,9 @@ g_subprocess_communicate_internal (GSubprocess         *subprocess,
     {
       state->cancellable_source = g_cancellable_source_new (cancellable);
       /* No ref held here, but we unref the source from state's free function */
-      g_source_set_callback (state->cancellable_source, g_subprocess_communicate_cancelled, state, NULL);
+      g_source_set_callback (state->cancellable_source,
+                             G_SOURCE_FUNC (g_subprocess_communicate_cancelled),
+                             state, NULL);
       g_source_attach (state->cancellable_source, g_main_context_get_thread_default ());
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]