From 9d9870db0d89e8f7f72de8ff5c9d37c8d9eb15c2 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 3 Mar 2013 14:25:54 +0100 Subject: [PATCH] Fixed some memory leaks --- src/data/gnumeric-reader.c | 3 +-- src/data/ods-reader.c | 14 +++++++++++++- src/language/data-io/get-data.c | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index 514616ace7..578ff8ab4b 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -175,6 +175,7 @@ gnumeric_get_sheet_range (struct spreadsheet *s, int n) static void gnm_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) { + int i; struct gnumeric_reader *r = r_; if ( r == NULL) return ; @@ -188,7 +189,6 @@ gnm_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) caseproto_unref (r->proto); -#if 0 for (i = 0; i < r->spreadsheet.n_sheets; ++i) { xmlFree (r->sheets[i].name); @@ -198,7 +198,6 @@ gnm_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) free (r); -#endif } static void diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index cb16dbc694..97f9e33441 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -209,6 +209,7 @@ ods_get_sheet_range (struct spreadsheet *s, int n) static void ods_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) { + int i; struct ods_reader *r = r_; if ( r == NULL) return ; @@ -227,7 +228,16 @@ ods_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) caseproto_unref (r->proto); - // free (r); + xmlFree (r->current_sheet_name); + + for (i = 0; i < r->n_allocated_sheets; ++i) + { + xmlFree (r->sheets[i].name); + } + + free (r->sheets); + + free (r); } static void @@ -298,6 +308,8 @@ process_node (struct ods_reader *r) if (! xmlTextReaderIsEmptyElement (r->xtr)) r->state = STATE_ROW; + + xmlFree (value); } else if (0 == xmlStrcasecmp (name, _xml("table:table")) && (XML_READER_TYPE_END_ELEMENT == r->node_type)) diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 3530c0e04e..2879e34a4b 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -103,6 +103,8 @@ cmd_get_data (struct lexer *lexer, struct dataset *ds) dict = spreadsheet->dict; } + free (filename); + if (reader) { dataset_set_dict (ds, dict); -- 2.30.2