giochannel: avoid setting uninitialised length

Our internal call to g_io_channel_read_line_backend() may return
G_IO_STATUS_ERROR, in which case two things will be true:

 - the GError will have been set (if appropriate)

 - the &got_length return value may not have been set

Since it's our convention to leave 'out' parameters untouched in
exception cases, this is perfectly fine.  Unfortunately,
g_io_channel_read_line(), in wrapping this internal function, always
promotes the length parameter, even in the case of error.

Stop doing that in order to avoid overwriting the callers's variable
with junk in the error case.

https://bugzilla.gnome.org/show_bug.cgi?id=731339
This commit is contained in:
Ryan Lortie 2014-06-06 12:16:55 -04:00 committed by Matthias Clasen
parent 88b284c070
commit 0007376128

View File

@ -1657,7 +1657,7 @@ g_io_channel_read_line (GIOChannel *channel,
status = g_io_channel_read_line_backend (channel, &got_length, terminator_pos, error);
if (length)
if (length && status != G_IO_STATUS_ERROR)
*length = got_length;
if (status == G_IO_STATUS_NORMAL)