Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,17 +928,16 @@ static int php_zip_has_property(zend_object *object, zend_string *name, int type
if (hnd != NULL) {
zval tmp, *prop;

if (type == 2) {
if (type == ZEND_PROPERTY_EXISTS) {
retval = true;
} else if ((prop = php_zip_property_reader(obj, hnd, &tmp)) != NULL) {
if (type == 1) {
if (type == ZEND_PROPERTY_NOT_EMPTY) {
retval = zend_is_true(&tmp);
} else if (type == 0) {
} else if (type == ZEND_PROPERTY_ISSET) {
retval = (Z_TYPE(tmp) != IS_NULL);
}
zval_ptr_dtor(&tmp);
}

zval_ptr_dtor(&tmp);
} else {
retval = zend_std_has_property(object, name, type, cache_slot);
}
Expand Down
20 changes: 20 additions & 0 deletions ext/zip/tests/property_existence_test.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Property existence test can cause a crash
--EXTENSIONS--
zip
--FILE--
<?php

$archive = new ZipArchive(__DIR__.'/property_existence.zip');
var_dump(array_column([$archive], 'lastId'));

?>
--CLEAN--
<?php
@unlink(__DIR__.'/property_existence.zip');
?>
--EXPECT--
array(1) {
[0]=>
int(-1)
}