[json-glib/wip/ordered-iter: 12/15] Plug leaks in json-glib-format
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib/wip/ordered-iter: 12/15] Plug leaks in json-glib-format
- Date: Mon, 24 Aug 2020 16:44:20 +0000 (UTC)
commit 67ce7b204483894fffb7ea6feddcbac00bc1a9bf
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Aug 24 15:52:34 2020 +0100
Plug leaks in json-glib-format
We're leaking a bunch of strings in error paths, as well as the stream
for the input file.
json-glib/json-glib-format.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/json-glib/json-glib-format.c b/json-glib/json-glib-format.c
index 481b4d3..7a3ca26 100644
--- a/json-glib/json-glib-format.c
+++ b/json-glib/json-glib-format.c
@@ -93,12 +93,15 @@ format (JsonParser *parser,
parse_res = json_parser_load_from_stream (parser, in, NULL, &error);
if (!parse_res)
{
+ char *uri = g_file_get_uri (file);
+
/* Translators: the first %s is the program name, the second one
* is the URI of the file, the third is the error message.
*/
g_printerr (_("%s: %s: error parsing file: %s\n"),
- g_get_prgname (), g_file_get_uri (file), error->message);
+ g_get_prgname (), uri, error->message);
g_clear_error (&error);
+ g_free (uri);
res = FALSE;
goto out;
}
@@ -132,10 +135,13 @@ format (JsonParser *parser,
if (written == -1 && errno != EINTR)
{
+ char *uri = g_file_get_uri (file);
+
/* Translators: the first %s is the program name, the
* second one is the URI of the file.
*/
- g_printerr (_("%s: %s: error writing to stdout"), g_get_prgname (), g_file_get_uri (file));
+ g_printerr (_("%s: %s: error writing to stdout"), g_get_prgname (), uri);
+ g_free (uri);
res = FALSE;
goto out;
}
@@ -153,15 +159,20 @@ out:
close_res = g_input_stream_close (in, NULL, &error);
if (!close_res)
{
+ char *uri = g_file_get_uri (file);
+
/* Translators: the first %s is the program name, the second one
* is the URI of the file, the third is the error message.
*/
g_printerr (_("%s: %s: error closing: %s\n"),
- g_get_prgname (), g_file_get_uri (file), error->message);
+ g_get_prgname (), uri, error->message);
g_clear_error (&error);
+ g_free (uri);
res = FALSE;
}
+ g_object_unref (in);
+
if (fd != STDOUT_FILENO)
g_close (fd, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]