Issue #2379 - Crash on saving

file_save(): make sure we always set an error on failure

file_save_dialog_save_image(): additionally, check that "error" exists
before dereferencing it.

(cherry picked from commit c55f2308e1)
This commit is contained in:
Michael Natterer
2018-10-31 23:46:06 +01:00
parent ed7f9454c1
commit a33a629bd9
2 changed files with 14 additions and 3 deletions

View File

@ -798,7 +798,8 @@ file_save_dialog_save_image (GimpProgress *progress,
{
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
_("Saving '%s' failed:\n\n%s"),
gimp_file_get_utf8_name (file), error->message);
gimp_file_get_utf8_name (file),
error ? error->message : _("Unknown error"));
g_clear_error (&error);
}
break;

View File

@ -94,7 +94,11 @@ file_save (Gimp *gimp,
drawable = gimp_image_get_active_drawable (image);
if (! drawable)
goto out;
{
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("There is no active layer to save"));
goto out;
}
/* FIXME enable these tests for remote files again, needs testing */
if (g_file_is_native (file) &&
@ -108,7 +112,13 @@ file_save (Gimp *gimp,
G_FILE_QUERY_INFO_NONE,
NULL, error);
if (! info)
goto out;
{
/* extra paranoia */
if (error && ! *error)
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Failed to get file information"));
goto out;
}
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
{