From 6c0f50efb568a6da52e6c31920bc93c4254063c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Dec 2009 19:42:54 +0100 Subject: archive/bz2: removed NULL check before g_free() g_free(NULL) is allowed. --- src/archive/bz2_plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/archive') diff --git a/src/archive/bz2_plugin.c b/src/archive/bz2_plugin.c index 4db68f48e..78f13400a 100644 --- a/src/archive/bz2_plugin.c +++ b/src/archive/bz2_plugin.c @@ -140,8 +140,8 @@ static void bz2_close(struct archive_file *file) { bz2_context *context = (bz2_context *) file; - if (context->name) - g_free(context->name); + + g_free(context->name); input_stream_close(&context->istream); g_free(context); -- cgit v1.2.3 From 3411f6cffdcf3c72e7cee3a263c40414dfef956e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Dec 2009 19:45:50 +0100 Subject: archive: close archive when stream is closed Fixes a memory leak: the "archive" input plugin opens the archive, but never closes it. This patch moves the responsibility for doing that to archive_plugin.open_stream(). This is an slight internal API change, but it is the simplest and least intrusive fix for the memory leak. --- src/archive/bz2_plugin.c | 2 ++ src/archive/iso_plugin.c | 2 ++ src/archive/zip_plugin.c | 2 ++ 3 files changed, 6 insertions(+) (limited to 'src/archive') diff --git a/src/archive/bz2_plugin.c b/src/archive/bz2_plugin.c index 78f13400a..0ef042e90 100644 --- a/src/archive/bz2_plugin.c +++ b/src/archive/bz2_plugin.c @@ -173,6 +173,8 @@ bz2_is_close(struct input_stream *is) bz2_context *context = (bz2_context *) is->data; bz2_destroy(context); is->data = NULL; + + bz2_close((struct archive_file *)context); } static int diff --git a/src/archive/iso_plugin.c b/src/archive/iso_plugin.c index d295f148f..7d2c075b1 100644 --- a/src/archive/iso_plugin.c +++ b/src/archive/iso_plugin.c @@ -165,6 +165,8 @@ iso_is_close(struct input_stream *is) { iso_context *context = (iso_context *) is->data; g_free(context->statbuf); + + iso_close((struct archive_file *)context); } diff --git a/src/archive/zip_plugin.c b/src/archive/zip_plugin.c index dbd2534fa..2f08b3812 100644 --- a/src/archive/zip_plugin.c +++ b/src/archive/zip_plugin.c @@ -133,6 +133,8 @@ zip_is_close(struct input_stream *is) { zip_context *context = (zip_context *) is->data; zzip_file_close (context->file); + + zip_close((struct archive_file *)context); } static size_t -- cgit v1.2.3 From 9179f108a540dcd27dafeb015778cc4dd873dfe5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Dec 2009 19:56:38 +0100 Subject: iso, zip: fixed memory leak in destructor Free the "context" pointer in the method archive_plugin.close(). --- src/archive/iso_plugin.c | 3 ++- src/archive/zip_plugin.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/archive') diff --git a/src/archive/iso_plugin.c b/src/archive/iso_plugin.c index 7d2c075b1..9063af0fc 100644 --- a/src/archive/iso_plugin.c +++ b/src/archive/iso_plugin.c @@ -132,7 +132,8 @@ iso_close(struct archive_file *file) } //close archive iso9660_close(context->iso); - context->iso = NULL; + + g_free(context); } /* single archive handling */ diff --git a/src/archive/zip_plugin.c b/src/archive/zip_plugin.c index 2f08b3812..243d46418 100644 --- a/src/archive/zip_plugin.c +++ b/src/archive/zip_plugin.c @@ -99,7 +99,8 @@ zip_close(struct archive_file *file) } //close archive zzip_dir_close (context->dir); - context->dir = NULL; + + g_free(context); } /* single archive handling */ -- cgit v1.2.3