evince r3440 - in trunk: . libdocument
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: evince r3440 - in trunk: . libdocument
- Date: Sun, 15 Feb 2009 13:51:43 +0000 (UTC)
Author: chpe
Date: Sun Feb 15 13:51:42 2009
New Revision: 3440
URL: http://svn.gnome.org/viewvc/evince?rev=3440&view=rev
Log:
* 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.
Modified:
trunk/ChangeLog
trunk/libdocument/ev-file-helpers.c
Modified: trunk/libdocument/ev-file-helpers.c
==============================================================================
--- trunk/libdocument/ev-file-helpers.c (original)
+++ trunk/libdocument/ev-file-helpers.c Sun Feb 15 13:51:42 2009
@@ -212,9 +212,9 @@
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 @@
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 @@
gssize size_read;
guchar buffer[1024];
gboolean retval;
+ gchar *content_type, *mime_type;
file = g_file_new_for_uri (uri);
@@ -264,9 +267,15 @@
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;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]