]> www.fi.muni.cz Git - evince.git/commitdiff
NULL safety. (get_mime_type_from_data): Return the MIME type, not the
authorChristian Persch <chpe@src.gnome.org>
Sun, 15 Feb 2009 13:51:42 +0000 (13:51 +0000)
committerChristian Persch <chpe@src.gnome.org>
Sun, 15 Feb 2009 13:51:42 +0000 (13:51 +0000)
* 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

ChangeLog
libdocument/ev-file-helpers.c

index 22f2cd5f1228d298585d08d9054941b2c9f71639..135e5a167e1ea3dd033f1e0fe3556c9863e100ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-13  Christian Persch  <chpe@gnome.org>
+
+       * 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.
+
 2009-02-13  Christian Persch  <chpe@gnome.org>
 
        * libdocument/ev-file-helpers.c: (get_mime_type_from_data): Don't leak
index 8811f25c94c40c7ff729c397edf0bdf11baf6674..7659562af87532f487a29816d127f7779270903b 100644 (file)
@@ -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;
 }
 
 /**