Commit 9ab781bd authored by Ell's avatar Ell

app: avoid CRITICAL when writing 0-length data to XCF

In xcf_write_int8(), avoid calling g_output_stream_write_all() with
data == NULL and count == 0, in which case it raises a CRITICAL and
doesn't set bytes_written, which we proceed to use uninitialized.
This can happen, e.g., when writing an empty parasite.

(cherry picked from commit 8e798e9c)
parent 26df5752
......@@ -35,17 +35,23 @@ xcf_write_int8 (XcfInfo *info,
gint count,
GError **error)
{
GError *my_error = NULL;
gsize bytes_written;
GError *my_error = NULL;
gsize bytes_written = 0;
if (! g_output_stream_write_all (info->output, data, count,
&bytes_written, NULL, &my_error))
/* we allow for 'data == NULL && count == 0', which
* g_output_stream_write_all() rejects.
*/
if (count > 0)
{
g_propagate_prefixed_error (error, my_error,
_("Error writing XCF: "));
}
if (! g_output_stream_write_all (info->output, data, count,
&bytes_written, NULL, &my_error))
{
g_propagate_prefixed_error (error, my_error,
_("Error writing XCF: "));
}
info->cp += bytes_written;
info->cp += bytes_written;
}
return bytes_written;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment