gdump: Do not overwrite GError contents

In case of multiple IO failures we may try to use a GError multiple
times, avoid so.

See: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/411#note_1812951
This commit is contained in:
Marco Trevisan (Treviño) 2023-08-11 00:42:10 +02:00 committed by Marco Trevisan
parent d3d6fd6809
commit b347a44e5e

11
gdump.c
View File

@ -669,14 +669,11 @@ g_irepository_dump (const char *arg, GError **error)
goutput_write (G_OUTPUT_STREAM (output), "</dump>\n");
{
GError **ioerror;
/* Avoid overwriting an earlier set error */
if (caught_error)
ioerror = NULL;
else
ioerror = error;
caught_error |= !g_input_stream_close (G_INPUT_STREAM (in), NULL, ioerror);
caught_error |= !g_output_stream_close (G_OUTPUT_STREAM (output), NULL, ioerror);
caught_error |= !g_input_stream_close (G_INPUT_STREAM (in), NULL,
caught_error ? NULL : error);
caught_error |= !g_output_stream_close (G_OUTPUT_STREAM (output), NULL,
caught_error ? NULL : error);
}
g_object_unref (in);