]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Memory leak in Solipa::gtktreemodel_to_csv.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 12 Aug 2015 09:59:48 +0000 (11:59 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 12 Aug 2015 10:01:54 +0000 (12:01 +0200)
src/utils.c

index 0df8d6b6caa55c1b3381da5a110dedb8e3b76a8d..776c91108ed7e121d4a7a9034fbc018f72f9ae0d 100644 (file)
@@ -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;
 }