From 28eb9283b1eccff2a04860613b61734293c2f141 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 12 Aug 2015 11:59:48 +0200 Subject: [PATCH] Memory leak in Solipa::gtktreemodel_to_csv. --- src/utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils.c b/src/utils.c index 0df8d6b..776c911 100644 --- a/src/utils.c +++ b/src/utils.c @@ -165,8 +165,8 @@ solipa_gtktreemodel_to_csv (GtkTreeModel *model, const gchar *filename, g_return_val_if_fail (columns != NULL, FALSE); g_return_val_if_fail (n_columns > 0, FALSE); - _filename = g_strstrip (g_strdup (filename)); - g_return_val_if_fail (g_strcmp0 (_filename, "") != 0, FALSE); + _filename = g_strdup (filename); + g_return_val_if_fail (g_strcmp0 (g_strstrip (_filename), "") != 0, FALSE); ret = TRUE; @@ -207,6 +207,9 @@ solipa_gtktreemodel_to_csv (GtkTreeModel *model, const gchar *filename, } if (ostream == NULL) { + g_free (_filename); + g_free (_quote); + g_free (_separator); g_warning ("Errore nella creazione del file di output: %s", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); return FALSE; @@ -229,6 +232,9 @@ solipa_gtktreemodel_to_csv (GtkTreeModel *model, const gchar *filename, if (!g_output_stream_write_all (G_OUTPUT_STREAM (ostream), row, strlen (row), NULL, NULL, &error)) { + g_free (_filename); + g_free (_quote); + g_free (_separator); g_warning ("Errore nella scrittura del file di output: %s", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); return FALSE; @@ -265,6 +271,10 @@ solipa_gtktreemodel_to_csv (GtkTreeModel *model, const gchar *filename, g_warning ("Nessun record da esportare."); } + g_free (_filename); + g_free (_quote); + g_free (_separator); + return ret; } -- 2.49.0