Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument/ev-file-helpers.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2009-02-15 13:51:42 (GMT)
committer Christian Persch <chpe@src.gnome.org>2009-02-15 13:51:42 (GMT)
commiteb04fe50682005da212c0c796ea3fa589d744212 (patch)
tree6e6f1e52552370d8812ed505d90af6a0b4d38f4c /libdocument/ev-file-helpers.c
parent47a708110ac25d902940d67d30f4eb14e8b427bb (diff)
NULL safety. (get_mime_type_from_data): Return the MIME type, not the
* libdocument/ev-file-helpers.c: (get_mime_type_from_uri): NULL safety. (get_mime_type_from_data): Return the MIME type, not the content type. svn path=/trunk/; revision=3440
Diffstat (limited to 'libdocument/ev-file-helpers.c')
-rw-r--r--libdocument/ev-file-helpers.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 8811f25..7659562 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -212,9 +212,9 @@ ev_xfer_uri_simple (const char *from,
static gchar *
get_mime_type_from_uri (const gchar *uri, GError **error)
{
- GFile *file;
- GFileInfo *file_info;
- gchar *mime_type;
+ GFile *file;
+ GFileInfo *file_info;
+ const gchar *content_type;
file = g_file_new_for_uri (uri);
file_info = g_file_query_info (file,
@@ -225,11 +225,13 @@ get_mime_type_from_uri (const gchar *uri, GError **error)
if (file_info == NULL)
return NULL;
- mime_type = g_content_type_get_mime_type (
- g_file_info_get_content_type (file_info));
+ content_type = g_file_info_get_content_type (file_info);
g_object_unref (file_info);
- return mime_type;
+ if (!content_type)
+ return NULL;
+
+ return g_content_type_get_mime_type (content_type);
}
static gchar *
@@ -240,6 +242,7 @@ get_mime_type_from_data (const gchar *uri, GError **error)
gssize size_read;
guchar buffer[1024];
gboolean retval;
+ gchar *content_type, *mime_type;
file = g_file_new_for_uri (uri);
@@ -264,9 +267,15 @@ get_mime_type_from_data (const gchar *uri, GError **error)
if (!retval)
return NULL;
- return g_content_type_guess (NULL, /* no filename */
- buffer, size_read,
- NULL);
+ content_type = g_content_type_guess (NULL, /* no filename */
+ buffer, size_read,
+ NULL);
+ if (!content_type)
+ return NULL;
+
+ mime_type = g_content_type_get_mime_type (content_type);
+ g_free (content_type);
+ return mime_type;
}
/**