summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2016-08-11 08:58:00 +0200
committerOndrej Holy <oholy@redhat.com>2016-08-23 08:37:13 +0200
commit76e12748bd0e519caeeefd6e1ac7ce8086e63059 (patch)
tree63bf014e342520f3da6962e382704d15470ff994
parent309b74cc2ca741888e3352888844a2d8cfdf08b8 (diff)
downloadlibgdata-76e12748bd0e519caeeefd6e1ac7ce8086e63059.tar.gz
core: Fix crashes on zero-length files
reached_eof is set too early and thus it may not be propagated properly in some cases, which may cause abortion when reading zero-length files. https://bugzilla.gnome.org/show_bug.cgi?id=769727
-rw-r--r--gdata/gdata-buffer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdata/gdata-buffer.c b/gdata/gdata-buffer.c
index c8c1298f..ce40f80f 100644
--- a/gdata/gdata-buffer.c
+++ b/gdata/gdata-buffer.c
@@ -231,10 +231,6 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
g_mutex_lock (&(self->mutex));
- /* Set reached_eof */
- if (reached_eof != NULL)
- *reached_eof = self->reached_eof && length_requested >= self->total_length;
-
if (self->reached_eof == TRUE && length_requested > self->total_length) {
/* Return data up to the EOF */
return_length = self->total_length;
@@ -259,6 +255,10 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
return_length = length_requested;
}
+ /* Set reached_eof */
+ if (reached_eof != NULL)
+ *reached_eof = self->reached_eof && length_requested >= self->total_length;
+
/* Return if we haven't got any data to pop (i.e. if we were cancelled before even one chunk arrived) */
if (return_length == 0)
goto done;