]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-file-helpers.c
Fix a freed memory read.
[evince.git] / libdocument / ev-file-helpers.c
index 7b9a9e9cfbe30ed4d8a468d402f9fb02ae2bf92b..67e884a4ee4e47959c135dc3bfb0a4dae7f10ba8 100644 (file)
@@ -222,6 +222,7 @@ get_mime_type_from_uri (const gchar *uri, GError **error)
        GFile       *file;
        GFileInfo   *file_info;
        const gchar *content_type;
+        gchar       *mime_type = NULL;
 
        file = g_file_new_for_uri (uri);
        file_info = g_file_query_info (file,
@@ -233,12 +234,12 @@ get_mime_type_from_uri (const gchar *uri, GError **error)
                return NULL;
 
        content_type = g_file_info_get_content_type (file_info);
-       g_object_unref (file_info);
-
-       if (!content_type)
-               return NULL;
+       if (content_type) {
+                mime_type = g_content_type_get_mime_type (content_type);
+        }
 
-       return g_content_type_get_mime_type (content_type);
+       g_object_unref (file_info);
+       return mime_type;
 }
 
 static gchar *