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
This commit is contained in:
Ryan Lortie 2014-03-02 21:01:12 -05:00
parent de142c0c5a
commit 9f71965bec

View File

@ -1420,7 +1420,7 @@ g_subprocess_communicate_made_progress (GObject *source_object,
source == state->stdout_buf || source == state->stdout_buf ||
source == state->stderr_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; goto out;
if (source == state->stdout_buf || if (source == state->stdout_buf ||