From cf8148df5e0eb91ada451d8aae9f35b0e832f138 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 29 Jun 2019 13:14:14 +0200 Subject: [PATCH] Issue #3093 - Invalid characters in Open Location dialog crashes GIMP file_open_location_response(): guard against g_file_new_for_uri() returning NULL (which it shouldn't) and an error being NULL (which it shouldn't either for the same reason). Spotted by Massimo. --- app/dialogs/file-open-location-dialog.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/dialogs/file-open-location-dialog.c b/app/dialogs/file-open-location-dialog.c index 6b101909fb..f0baa4e0ef 100644 --- a/app/dialogs/file-open-location-dialog.c +++ b/app/dialogs/file-open-location-dialog.c @@ -198,6 +198,10 @@ file_open_location_response (GtkDialog *dialog, { GFile *entered_file = g_file_new_for_uri (text); + /* should not fail but does, see issue #3093 */ + if (! entered_file) + entered_file = g_object_ref (file); + gtk_widget_show (box); gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE); @@ -236,7 +240,9 @@ file_open_location_response (GtkDialog *dialog, { gimp_message (gimp, G_OBJECT (box), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), - text, error->message); + text, + /* error should never be NULL, also issue #3093 */ + error ? error->message : _("Invalid URI")); g_clear_error (&error); } }