Fix: Take care of uninitialized variable condition
authorDenis Kenzior <denkenz@gmail.com>
Thu, 28 Jan 2010 20:31:22 +0000 (14:31 -0600)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 28 Jan 2010 20:41:46 +0000 (21:41 +0100)
In some (impossible) circumstances rbytes and err might be used
uninitialized.  Here we make a check that a read was actually attempted
before checking those variables.

gatchat/gatchat.c

index 336a423..f60f857 100644 (file)
@@ -704,10 +704,8 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
        do {
                toread = ring_buffer_avail_no_wrap(chat->buf);
 
-               if (toread == 0) {
-                       err = G_IO_ERROR_NONE;
+               if (toread == 0)
                        break;
-               }
 
                rbytes = 0;
                buf = ring_buffer_write_ptr(chat->buf);
@@ -732,7 +730,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
        if (cond & (G_IO_HUP | G_IO_ERR))
                return FALSE;
 
-       if (rbytes == 0 && err != G_IO_ERROR_AGAIN)
+       if (read_count > 0 && rbytes == 0 && err != G_IO_ERROR_AGAIN)
                return FALSE;
 
        return TRUE;