evince r3452 - in trunk: . backend/comics



Author: chpe
Date: Sun Feb 15 13:52:50 2009
New Revision: 3452
URL: http://svn.gnome.org/viewvc/evince?rev=3452&view=rev

Log:
	* backend/comics/comics-document.c: (comics_document_load): Make sure
	to always set @error when returning FALSE.

Modified:
   trunk/ChangeLog
   trunk/backend/comics/comics-document.c

Modified: trunk/backend/comics/comics-document.c
==============================================================================
--- trunk/backend/comics/comics-document.c	(original)
+++ trunk/backend/comics/comics-document.c	Sun Feb 15 13:52:50 2009
@@ -114,12 +114,27 @@
 	gchar **cbr_files;
 	gboolean success;
 	int i, retval;
+	GError *err = NULL;
 
 	comics_document->archive = g_filename_from_uri (uri, NULL, error);
-	g_return_val_if_fail (comics_document->archive != NULL, FALSE);
+	if (!comics_document->archive)
+		return FALSE;
+
+	mime_type = ev_file_get_mime_type (uri, FALSE, &err);
+	if (!mime_type) {
+		if (err) {
+			g_propagate_error (error, err);
+		} else {
+			g_set_error_literal (error,
+					      EV_DOCUMENT_ERROR,
+					      EV_DOCUMENT_ERROR_INVALID,
+					      _("Unknown MIME Type"));
+		}
+
+		return FALSE;
+	}
 
 	quoted_file = g_shell_quote (comics_document->archive);
-	mime_type = ev_file_get_mime_type (uri, FALSE, NULL);
 
 	/* FIXME, use proper cbr/cbz mime types once they're
 	 * included in shared-mime-info */
@@ -143,6 +158,15 @@
 		list_files_command = 
 			g_strdup_printf ("7zr l -- %s", quoted_file);
 		comics_document->regex_arg = TRUE;
+	} else {
+		g_set_error (error,
+			     EV_DOCUMENT_ERROR,
+			     EV_DOCUMENT_ERROR_INVALID,
+			     _("Not a comic book MIME type: %s"),
+			     mime_type);
+		g_free (mime_type);
+		g_free (quoted_file);
+		return FALSE;
 	}
 
 	g_free (mime_type);
@@ -163,7 +187,18 @@
 		return FALSE;
 	}
 
+	/* FIXME: is this safe against filenames containing \n in the archive ? */
 	cbr_files = g_strsplit (std_out, "\n", 0);
+	g_free (std_out);
+
+	if (!cbr_files) {
+		g_set_error_literal (error,
+				     EV_DOCUMENT_ERROR,
+				     EV_DOCUMENT_ERROR_INVALID,
+				     _("No files in archive."));
+		return FALSE;
+	}
+
 	supported_extensions = get_supported_image_extensions ();
 	for (i = 0; cbr_files[i] != NULL; i++) {
 		gchar *suffix = g_strrstr (cbr_files[i], ".");
@@ -184,7 +219,6 @@
 		g_free (suffix);
 	}
 
-	g_free (std_out);
 	g_strfreev (cbr_files);
 	g_slist_foreach (supported_extensions, (GFunc) g_free, NULL);
 	g_slist_free (supported_extensions);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]