Skip to content

Commit 3e4e305

Browse files
committed
Fix crash in property existence test, apply to all versions
1 parent 45e99a1 commit 3e4e305

7 files changed

Lines changed: 10 additions & 12 deletions

File tree

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<license uri="https://www.php.net/license/3_01.txt" filesource="LICENSE">PHP-3.01</license>
2929
<notes>
3030
- Fixed bug GH-19932 Memory leak in zip setEncryptionName()/setEncryptionIndex() (David Carlier)
31+
- Fix crash in property existence test. (ndossche)
3132
</notes>
3233
<contents>
3334
<dir name="/">

php7/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,8 @@ static int php_zip_has_property(zval *object, zval *member, int type, void **cac
10501050
} else if (type == 0) {
10511051
retval = (Z_TYPE(tmp) != IS_NULL);
10521052
}
1053+
zval_ptr_dtor(&tmp);
10531054
}
1054-
1055-
zval_ptr_dtor(&tmp);
10561055
} else {
10571056
std_hnd = zend_get_std_object_handlers();
10581057
retval = std_hnd->has_property(object, member, type, cache_slot);

php73/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,8 @@ static int php_zip_has_property(zval *object, zval *member, int type, void **cac
10541054
} else if (type == 0) {
10551055
retval = (Z_TYPE(tmp) != IS_NULL);
10561056
}
1057+
zval_ptr_dtor(&tmp);
10571058
}
1058-
1059-
zval_ptr_dtor(&tmp);
10601059
} else {
10611060
retval = zend_std_has_property(object, member, type, cache_slot);
10621061
}

php74/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,8 @@ static int php_zip_has_property(zval *object, zval *member, int type, void **cac
10661066
} else if (type == 0) {
10671067
retval = (Z_TYPE(tmp) != IS_NULL);
10681068
}
1069+
zval_ptr_dtor(&tmp);
10691070
}
1070-
1071-
zval_ptr_dtor(&tmp);
10721071
} else {
10731072
retval = zend_std_has_property(object, member, type, cache_slot);
10741073
}

php8/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ static int php_zip_has_property(zend_object *object, zend_string *name, int type
972972
} else if (type == 0) {
973973
retval = (Z_TYPE(tmp) != IS_NULL);
974974
}
975+
zval_ptr_dtor(&tmp);
975976
}
976-
977-
zval_ptr_dtor(&tmp);
978977
} else {
979978
retval = zend_std_has_property(object, name, type, cache_slot);
980979
}

php85/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,8 @@ static int php_zip_has_property(zend_object *object, zend_string *name, int type
934934
} else if (type == 0) {
935935
retval = (Z_TYPE(tmp) != IS_NULL);
936936
}
937+
zval_ptr_dtor(&tmp);
937938
}
938-
939-
zval_ptr_dtor(&tmp);
940939
} else {
941940
retval = zend_std_has_property(object, name, type, cache_slot);
942941
}

tests/property_existence_test.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
--TEST--
22
Property existence test can cause a crash
3-
--EXTENSIONS--
4-
zip
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('zip')) die('skip');
6+
?>
57
--FILE--
68
<?php
79

0 commit comments

Comments
 (0)