(task_database) Fix leaks when scanning zip files

This commit is contained in:
Higor Eurípedes 2015-07-05 10:23:21 -03:00
parent b133499071
commit 3cc6e07174
3 changed files with 18 additions and 0 deletions

View File

@ -617,7 +617,10 @@ int zlib_parse_file_iterate(void *data, bool *returnerr, const char *file,
*returnerr = false;
case ZLIB_TRANSFER_DEINIT:
if (state->handle)
{
state->backend->free(state->handle);
state->handle = NULL;
}
break;
}
@ -628,6 +631,16 @@ int zlib_parse_file_iterate(void *data, bool *returnerr, const char *file,
return 0;
}
void zlib_parse_file_iterate_stop(void *data)
{
zlib_transfer_t *state = (zlib_transfer_t*)data;
if (!state || !state->handle)
return;
state->type = ZLIB_TRANSFER_DEINIT;
zlib_parse_file_iterate(data, NULL, NULL, NULL, NULL, NULL);
}
/**
* zlib_parse_file:
* @file : filename path of archive

View File

@ -83,6 +83,8 @@ int zlib_parse_file_iterate(void *data, bool *returnerr,
const char *file,
const char *valid_exts, zlib_file_cb file_cb, void *userdata);
void zlib_parse_file_iterate_stop(void *data);
/**
* zlib_extract_first_content_file:
* @zip_path : filename path to ZIP archive.

View File

@ -279,7 +279,10 @@ static int database_info_iterate_playlist_zip(
bool returnerr = true;
#ifdef HAVE_ZLIB
if (db_state->crc != 0)
{
zlib_parse_file_iterate_stop(&db->state);
return database_info_iterate_crc_lookup(db_state, db, db_state->zip_name);
}
else
{
if (zlib_parse_file_iterate(&db->state,