am 8750fa76: Merge "Make a copy of a prefix param in StartIteration"

* commit '8750fa76090ee735677022f5e2d73419dd7faa93':
  Make a copy of a prefix param in StartIteration
This commit is contained in:
Piotr Jastrzebski 2014-08-11 13:34:23 +00:00 committed by Android Git Automerger
commit af83392e5a
1 changed files with 7 additions and 1 deletions

View File

@ -899,10 +899,12 @@ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr, const char* p
IterationHandle* cookie = (IterationHandle*) malloc(sizeof(IterationHandle));
cookie->position = 0;
cookie->prefix = prefix;
cookie->archive = archive;
if (prefix != NULL) {
cookie->prefix = strdup(prefix);
cookie->prefix_len = strlen(prefix);
} else {
cookie->prefix = NULL;
}
*cookie_ptr = cookie ;
@ -911,6 +913,10 @@ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr, const char* p
void EndIteration(void* cookie) {
if (cookie != NULL) {
IterationHandle* handle = reinterpret_cast<IterationHandle*>(cookie);
if (handle->prefix != NULL) {
free(const_cast<char*>(handle->prefix));
}
free(cookie);
}
}