summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2007-06-03 21:21:57 +0000
committerPierre Joye <pajoye@php.net>2007-06-03 21:21:57 +0000
commitd5d2d6e30e2e3bab65a2083d4a1bc2219170778e (patch)
treea30b786a675414131e8cc31846d2d777ba5e85ae /ext/zip/php_zip.c
parenta4d68b26e404a6491fb636c6817c0af89e9f96a8 (diff)
downloadphp-git-d5d2d6e30e2e3bab65a2083d4a1bc2219170778e.tar.gz
- pecl bug #11216, better fix, leak removed and improved test
- typo in news, better late than never (-d)
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 5f56478949..662513a6c8 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -120,7 +120,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
len = spprintf(&file_dirname_fullpath, 0, "%s", dest);
}
- php_basename(file, file_len, NULL, 0, &file_basename, (unsigned int *)&file_basename_len TSRMLS_CC);
+ php_basename(file, file_len, NULL, 0, &file_basename, (size_t *)&file_basename_len TSRMLS_CC);
if (OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) {
efree(file_dirname_fullpath);
@@ -1005,7 +1005,6 @@ static ZIPARCHIVE_METHOD(addEmptyDir)
}
if (dirname[dirname_len-1] != '/') {
-
s=(char *)emalloc(dirname_len+2);
strcpy(s, dirname);
s[dirname_len] = '/';
@@ -1016,14 +1015,23 @@ static ZIPARCHIVE_METHOD(addEmptyDir)
idx = zip_stat(intern, s, 0, &sb);
if (idx >= 0) {
- RETURN_FALSE;
- }
+ RETVAL_FALSE;
+ } else {
+ /* reset the error */
+ if (intern->error.str) {
+ _zip_error_fini(&intern->error);
+ }
+ _zip_error_init(&intern->error);
- if (zip_add_dir(intern, (const char *)s) == -1) {
- RETURN_FALSE;
+ if (zip_add_dir(intern, (const char *)s) == -1) {
+ RETVAL_FALSE;
+ }
+ RETVAL_TRUE;
}
- RETURN_TRUE;
+ if (s != dirname) {
+ efree(s);
+ }
}
/* }}} */