From 485e3d8990ca9e4f4c39587db01d0facf954830a Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Thu, 28 Mar 2019 04:44:36 +0100 Subject: caja-open-with-dialog: make sure there is error before showing it Fixes Clang static analyzer warning: caja-open-with-dialog.c:252:100: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error') message = g_strdup_printf (_("Could not add application to the application database: %s"), error->message); ^~~~~~~~~~~~~~ --- libcaja-private/caja-open-with-dialog.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c index 45996fdf..e42a8fbd 100644 --- a/libcaja-private/caja-open-with-dialog.c +++ b/libcaja-private/caja-open-with-dialog.c @@ -249,12 +249,15 @@ add_or_find_application (CajaOpenWithDialog *dialog) if (app == NULL) { - message = g_strdup_printf (_("Could not add application to the application database: %s"), error->message); + message = g_strdup_printf (_("Could not add application to the application database: %s"), error ? error->message : _("Unknown error")); eel_show_error_dialog (_("Could not add application"), message, GTK_WINDOW (dialog)); g_free (message); - g_error_free (error); + + if (error) + g_error_free (error); + return NULL; } -- cgit v1.2.1