[glib/glib-2-56: 1/3] subprocess: Fix communicate_cancelled signature



commit 80a2648953cae4619e695cf7023bdb02cebc098f
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..2ce2428f0 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,
+                             (GSourceFunc) 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]