Make a copy of a prefix param in StartIteration

and delete it in EndIteration.

Change-Id: I4de4167700a9dba3119fde22fcd45725742f3731
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 366fb24..a29eb79 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -899,10 +899,12 @@
 
   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 @@
 
 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);
   }
 }