summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2006-08-13 23:43:11 +0000
committerPierre Joye <pajoye@php.net>2006-08-13 23:43:11 +0000
commit284ce40c4a50f42b66ac0dff58786b74e76493b7 (patch)
treefb8cd18bc5fc175db867234b8b2411edb73a874a /ext/zip/php_zip.c
parent8d07735332892b44880d701ffe6f8e119181dd8d (diff)
downloadphp-git-284ce40c4a50f42b66ac0dff58786b74e76493b7.tar.gz
- MFH: locateName should not change the state/error, can be used to test
an entry
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 27f0bb2dd7..0e46345f7a 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1153,6 +1153,7 @@ ZIPARCHIVE_METHOD(locateName)
char *name;
int name_len;
long flags = 0;
+ long idx = -1;
if (!this) {
RETURN_FALSE;
@@ -1169,7 +1170,18 @@ ZIPARCHIVE_METHOD(locateName)
RETURN_FALSE;
}
- RETURN_LONG((long)zip_name_locate(intern, (const char *)name, flags))
+ idx = (long)zip_name_locate(intern, (const char *)name, flags);
+
+ if (idx<0) {
+ /* reset the error */
+ if (intern->error.str) {
+ _zip_error_fini(&intern->error);
+ }
+ _zip_error_init(&intern->error);
+ RETURN_FALSE;
+ } else {
+ RETURN_LONG(idx);
+ }
}
/* }}} */