Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--libdocument/ev-file-helpers.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a9a512..6d46566 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-02-13 Christian Persch <chpe@gnome.org>
+ * libdocument/ev-file-helpers.c: (get_mime_type_from_data): Propagate
+ all errors upwards.
+
+2009-02-13 Christian Persch <chpe@gnome.org>
+
* libdocument/ev-file-helpers.c: (get_mime_type_from_data): Don't use
more bytes from buffer than were read from the file.
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 0b82536..8d51301 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -239,6 +239,7 @@ get_mime_type_from_data (const gchar *uri, GError **error)
GFileInputStream *input_stream;
gssize size_read;
guchar buffer[1024];
+ gboolean retval;
file = g_file_new_for_uri (uri);
@@ -249,12 +250,15 @@ get_mime_type_from_data (const gchar *uri, GError **error)
}
size_read = g_input_stream_read (G_INPUT_STREAM (input_stream),
- buffer, 1024, NULL, NULL);
- g_input_stream_close (G_INPUT_STREAM (input_stream), NULL, error);
+ buffer, sizeof (buffer), NULL, error);
+ if (size_read == -1) {
+ g_object_unref (file);
+ return NULL;
+ }
+ retval = g_input_stream_close (G_INPUT_STREAM (input_stream), NULL, error);
g_object_unref (file);
-
- if (size_read == -1)
+ if (!retval)
return NULL;
return g_content_type_guess (NULL, /* no filename */