summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-01-28 14:31:22 -0600
committerMarcel Holtmann <marcel@holtmann.org>2010-01-28 21:41:46 +0100
commit640e23b3e8f486b0174a861505d7c6269d5bcba2 (patch)
treec761f16019f9af880a435c27eacce8335a4d3cdb
parent47b376927ad96749f6509fe8ed211ce3ead39ac4 (diff)
downloadconnman-640e23b3e8f486b0174a861505d7c6269d5bcba2.tar.gz
connman-640e23b3e8f486b0174a861505d7c6269d5bcba2.tar.bz2
connman-640e23b3e8f486b0174a861505d7c6269d5bcba2.zip
Fix: Take care of uninitialized variable condition
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.
-rw-r--r--gatchat/gatchat.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 336a4238..f60f857a 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -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;