Commit d5e1af7d authored by Ell's avatar Ell

Issue #1783 - Xcf file crashing gimp-console-2.10 ...

... (Invalid read reported by valgrind)

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

(cherry picked from commit 6ebadea7)
parent 9f0f11f4
......@@ -37,12 +37,18 @@ xcf_read_int8 (XcfInfo *info,
guint8 *data,
gint count)
gsize bytes_read;
gsize bytes_read = 0;
g_input_stream_read_all (info->input, data, count,
&bytes_read, NULL, NULL);
/* we allow for 'data == NULL && count == 0', which g_input_stream_read_all()
* rejects.
if (count > 0)
g_input_stream_read_all (info->input, data, count,
&bytes_read, NULL, NULL);
info->cp += bytes_read;
info->cp += bytes_read;
return bytes_read;
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