diff options
author | Christian Persch <chpe@src.gnome.org> | 2009-02-15 13:51:30 (GMT) |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2009-02-15 13:51:30 (GMT) |
commit | f870dd6bcd19cbbe8f62a4c2b04c1c5bd440bd8b (patch) | |
tree | d2b6236ad52e40b1cecba00a8137f414da5cc13a | |
parent | 6d536b8815d57852153f260e9985f6d98effd9d1 (diff) |
Propagate all errors upwards.
* libdocument/ev-file-helpers.c: (get_mime_type_from_data): Propagate
all errors upwards.
svn path=/trunk/; revision=3438
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libdocument/ev-file-helpers.c | 12 |
2 files changed, 13 insertions, 4 deletions
@@ -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 */ |