43 lines
1.5 KiB
Diff
43 lines
1.5 KiB
Diff
From 76e12748bd0e519caeeefd6e1ac7ce8086e63059 Mon Sep 17 00:00:00 2001
|
|
From: Ondrej Holy <oholy@redhat.com>
|
|
Date: Thu, 11 Aug 2016 08:58:00 +0200
|
|
Subject: [PATCH] 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
|
|
---
|
|
gdata/gdata-buffer.c | 8 ++++----
|
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/gdata/gdata-buffer.c b/gdata/gdata-buffer.c
|
|
index c8c1298f00f7..ce40f80f6249 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;
|
|
--
|
|
2.5.5
|
|
|