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.
This commit is contained in:
parent
6c0f50efb5
commit
3411f6cffd
2
NEWS
2
NEWS
@ -1,4 +1,6 @@
|
|||||||
ver 0.15.7 (2009/??/??)
|
ver 0.15.7 (2009/??/??)
|
||||||
|
* archive:
|
||||||
|
- close archive when stream is closed
|
||||||
* input:
|
* input:
|
||||||
- file: don't fall back to parent directory
|
- file: don't fall back to parent directory
|
||||||
- archive: fixed memory leak in error handler
|
- archive: fixed memory leak in error handler
|
||||||
|
@ -173,6 +173,8 @@ bz2_is_close(struct input_stream *is)
|
|||||||
bz2_context *context = (bz2_context *) is->data;
|
bz2_context *context = (bz2_context *) is->data;
|
||||||
bz2_destroy(context);
|
bz2_destroy(context);
|
||||||
is->data = NULL;
|
is->data = NULL;
|
||||||
|
|
||||||
|
bz2_close((struct archive_file *)context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -165,6 +165,8 @@ iso_is_close(struct input_stream *is)
|
|||||||
{
|
{
|
||||||
iso_context *context = (iso_context *) is->data;
|
iso_context *context = (iso_context *) is->data;
|
||||||
g_free(context->statbuf);
|
g_free(context->statbuf);
|
||||||
|
|
||||||
|
iso_close((struct archive_file *)context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,6 +133,8 @@ zip_is_close(struct input_stream *is)
|
|||||||
{
|
{
|
||||||
zip_context *context = (zip_context *) is->data;
|
zip_context *context = (zip_context *) is->data;
|
||||||
zzip_file_close (context->file);
|
zzip_file_close (context->file);
|
||||||
|
|
||||||
|
zip_close((struct archive_file *)context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -73,6 +73,9 @@ struct archive_plugin {
|
|||||||
/**
|
/**
|
||||||
* Opens an input_stream of a file within the archive.
|
* Opens an input_stream of a file within the archive.
|
||||||
*
|
*
|
||||||
|
* If this function succeeds, then the #input_stream "owns"
|
||||||
|
* the archive file and will automatically close it.
|
||||||
|
*
|
||||||
* @param path the path within the archive
|
* @param path the path within the archive
|
||||||
*/
|
*/
|
||||||
bool (*open_stream)(struct archive_file *, struct input_stream *is,
|
bool (*open_stream)(struct archive_file *, struct input_stream *is,
|
||||||
|
Loading…
Reference in New Issue
Block a user