From 2409a4e2aba8f8c83365492f44e8c3c801b852f8 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 21 Aug 2006 13:38:28 +0000 Subject: Fix crash when opening a pdf with password protection. 2006-08-21 Carlos Garcia Campos * backend/ev-document-factory.c: (ev_document_factory_get_document): Fix crash when opening a pdf with password protection. --- (limited to 'backend/ev-document-factory.c') diff --git a/backend/ev-document-factory.c b/backend/ev-document-factory.c index 278a21a..3b3f701 100644 --- a/backend/ev-document-factory.c +++ b/backend/ev-document-factory.c @@ -296,15 +296,21 @@ ev_document_factory_get_document (const char *uri, GError **error) } result = ev_document_load (document, uri, error); - + if (result == FALSE || *error) { - if (document) - g_object_unref (document); - document = NULL; + if (*error && + (*error)->domain == EV_DOCUMENT_ERROR && + (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) + return document; } else { return document; } + /* Try again with slow mime detection */ + if (document) + g_object_unref (document); + document = NULL; + if (*error) g_error_free (*error); *error = NULL; @@ -316,20 +322,23 @@ ev_document_factory_get_document (const char *uri, GError **error) } result = ev_document_load (document, uri, error); - - if (result == FALSE || *error) { + + if (result == FALSE) { + if (*error == NULL) { + g_set_error (error, + EV_DOCUMENT_ERROR, + 0, + _("Unknown MIME Type")); + } else if ((*error)->domain == EV_DOCUMENT_ERROR && + (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) { + return document; + } + if (document) g_object_unref (document); document = NULL; } - - if (result == FALSE && *error == NULL) { - g_set_error (error, - EV_DOCUMENT_ERROR, - 0, - _("Unknown MIME Type")); - } - + return document; } -- cgit v0.9.1