[glib] gsubprocess: fix communicate() with empty buffers



commit 9f71965becd919a736cb57bbd3501b22e6341fa7
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Mar 2 21:01:12 2014 -0500

    gsubprocess: fix communicate() with empty buffers
    
    On the splice for stdout or stderr completing, GSubprocess calls
    _slice_finish() to collect the result.
    
    We assume that a zero return value here means failure, but in fact this
    function returns a gssize -- the number of bytes transferred, or -1 for
    an error.
    
    This causes GSubprocess to mistakenly think that it has an error when it
    actually just has an empty buffer (as would be the case when collecting
    stderr from a successful command).
    
    Check for -1 instead of FALSE to detect the error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724916

 gio/gsubprocess.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index c0f8367..19cbf57 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -1420,7 +1420,7 @@ g_subprocess_communicate_made_progress (GObject      *source_object,
       source == state->stdout_buf ||
       source == state->stderr_buf)
     {
-      if (!g_output_stream_splice_finish ((GOutputStream*)source, result, &error))
+      if (g_output_stream_splice_finish ((GOutputStream*) source, result, &error) == -1)
         goto out;
 
       if (source == state->stdout_buf ||


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