gdump: Fix leaked io streams

This makes Meson unit test fail:
https://github.com/mesonbuild/meson/issues/11754
This commit is contained in:
Xavier Claessens 2023-07-18 11:07:59 -04:00
parent 9a910e44aa
commit a194c42129

10
gdump.c
View File

@ -594,6 +594,7 @@ g_irepository_dump (const char *arg, GError **error)
if (output == NULL) if (output == NULL)
{ {
g_input_stream_close (G_INPUT_STREAM (input), NULL, NULL); g_input_stream_close (G_INPUT_STREAM (input), NULL, NULL);
g_object_unref (input);
return FALSE; return FALSE;
} }
@ -674,11 +675,12 @@ g_irepository_dump (const char *arg, GError **error)
ioerror = NULL; ioerror = NULL;
else else
ioerror = error; ioerror = error;
if (!g_input_stream_close (G_INPUT_STREAM (in), NULL, ioerror)) caught_error |= !g_input_stream_close (G_INPUT_STREAM (in), NULL, ioerror);
return FALSE; caught_error |= !g_output_stream_close (G_OUTPUT_STREAM (output), NULL, ioerror);
if (!g_output_stream_close (G_OUTPUT_STREAM (output), NULL, ioerror))
return FALSE;
} }
g_object_unref (in);
g_object_unref (output);
return !caught_error; return !caught_error;
} }