[gnumeric] xlsx: plug leaks.



commit b6e44360bfe6e643db5ac4b51b13d05c47f75e9e
Author: Morten Welinder <terra gnome org>
Date:   Sun Feb 8 15:28:57 2015 -0500

    xlsx: plug leaks.

 plugins/excel/ChangeLog            |    7 +++++++
 plugins/excel/xlsx-write-drawing.c |   12 +++++++++---
 plugins/excel/xlsx-write.c         |   17 ++++++++++++++---
 3 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index f3bf8fc..df73be4 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-08  Morten Welinder  <terra gnome org>
+
+       * xlsx-write-drawing.c (xlsx_write_drawing_objects): Add leak
+       checking.
+
+       * xlsx-write.c (xlsx_write_workbook): Plug leaks.
+
 2015-02-06  Morten Welinder  <terra gnome org>
 
        * xlsx-write.c (xlsx_write_sheet): Handle sheet widgets.
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index 5ba9453..eb3c1c6 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -1009,10 +1009,14 @@ xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part, GSList
        GsfOutput *drawing_part;
        GsfXMLOut *xml;
 
-       if (NULL == state->drawing.dir)
+       if (NULL == state->drawing.dir) {
                state->drawing.dir = (GsfOutfile *)gsf_outfile_new_child (state->xl_dir, "drawings", TRUE);
-       if (NULL == state->chart.dir)
+               go_debug_check_finalized (state->drawing.dir, "drawing.dir");
+       }
+       if (NULL == state->chart.dir) {
                state->chart.dir = (GsfOutfile *)gsf_outfile_new_child (state->xl_dir, "charts", TRUE);
+               go_debug_check_finalized (state->chart.dir, "chart.dir");
+       }
 
        name = g_strdup_printf ("drawing%u.xml", ++state->drawing.count);
        drawing_part = gsf_outfile_new_child_full (state->drawing.dir, name, FALSE,
@@ -1169,8 +1173,10 @@ xlsx_write_legacy_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
        parse_pos_init_sheet (&pp0, state->sheet);
 
        /* Note: we use drawing.dir here.  */
-       if (NULL == state->drawing.dir)
+       if (NULL == state->drawing.dir) {
                state->drawing.dir = (GsfOutfile *)gsf_outfile_new_child (state->xl_dir, "drawings", TRUE);
+               go_debug_check_finalized (state->drawing.dir, "drawing.dir");
+       }
 
        name = g_strdup_printf ("vmlDrawing%u.vml", ++state->legacy_drawing.count);
        drawing_part = gsf_outfile_new_child_full (state->drawing.dir, name, FALSE, NULL);
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index b68eab2..00ff443 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -3073,15 +3073,26 @@ xlsx_write_workbook (XLSXWriteState *state, GsfOutfile *root_part)
        g_ptr_array_free (state->dxfs_array, TRUE);
        g_hash_table_destroy (state->axids);
 
-       if (NULL != state->chart.dir)
+       if (NULL != state->chart.dir) {
                gsf_output_close (GSF_OUTPUT (state->chart.dir));
-       if (NULL != state->drawing.dir)
+               g_object_unref (state->chart.dir);
+       }
+       if (NULL != state->drawing.dir) {
                gsf_output_close (GSF_OUTPUT (state->drawing.dir));
+               g_object_unref (state->drawing.dir);
+       }
        /* legacy_drawing.dir is unused */
+
        gsf_output_close (GSF_OUTPUT (wb_part));
-       g_ptr_array_free (sheetIds, TRUE);
+       g_object_unref (wb_part);
+
        gsf_output_close (GSF_OUTPUT (sheet_dir));
+       g_object_unref (sheet_dir);
+
        gsf_output_close (GSF_OUTPUT (xl_dir));
+       g_object_unref (xl_dir);
+
+       g_ptr_array_free (sheetIds, TRUE);
 }
 
 G_MODULE_EXPORT void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]