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.
This commit is contained in:
@ -798,7 +798,8 @@ file_save_dialog_save_image (GimpProgress *progress,
|
|||||||
{
|
{
|
||||||
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
||||||
_("Saving '%s' failed:\n\n%s"),
|
_("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);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +94,11 @@ file_save (Gimp *gimp,
|
|||||||
drawable = gimp_image_get_active_drawable (image);
|
drawable = gimp_image_get_active_drawable (image);
|
||||||
|
|
||||||
if (! drawable)
|
if (! drawable)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
_("There is no active layer to save"));
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME enable these tests for remote files again, needs testing */
|
/* FIXME enable these tests for remote files again, needs testing */
|
||||||
if (g_file_is_native (file) &&
|
if (g_file_is_native (file) &&
|
||||||
@ -108,7 +112,13 @@ file_save (Gimp *gimp,
|
|||||||
G_FILE_QUERY_INFO_NONE,
|
G_FILE_QUERY_INFO_NONE,
|
||||||
NULL, error);
|
NULL, error);
|
||||||
if (! info)
|
if (! info)
|
||||||
|
{
|
||||||
|
/* extra paranoia */
|
||||||
|
if (error && ! *error)
|
||||||
|
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
_("Failed to get file information"));
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
|
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user