mirror of https://github.com/GNOME/gimp.git
tools: Don't crash when reading invalid Curves preset
When reading a gimp:curves preset file, we assume that we read in at least 64 bytes for the header. If the invalid preset file is smaller than that, g_input_stream_read_all () can read it just fine but the code fails when comparing the bytes read in to the size of the header. This means that the GError object is still NULL, so g_prefix_error () has no effect - and thus the calling code crashes when it tries to get "message" from a NULL GError object. To resolve this issue, we check if error or *error are NULL. If so, we set the error with g_set_error () instead.
This commit is contained in:
parent
43ae9fced5
commit
8b0185ba8f
|
@ -752,7 +752,11 @@ gimp_curves_tool_settings_import (GimpFilterTool *filter_tool,
|
|||
&bytes_read, NULL, error) ||
|
||||
bytes_read != sizeof (header))
|
||||
{
|
||||
g_prefix_error (error, _("Could not read header: "));
|
||||
if (error && *error)
|
||||
g_prefix_error (error, _("Could not read header: "));
|
||||
else
|
||||
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
||||
_("Could not read header: "));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue