[glib] giochannel: avoid setting uninitialised length



commit 000737612852d76fd1b85b42363901ec6ab12bd9
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jun 6 12:16:55 2014 -0400

    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

 glib/giochannel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/glib/giochannel.c b/glib/giochannel.c
index 447bb4f..1765233 100644
--- a/glib/giochannel.c
+++ b/glib/giochannel.c
@@ -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)


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