Skip to content

Commit

Permalink
Merge branch 'PHP-8.2'
Browse files Browse the repository at this point in the history
* PHP-8.2:
  Fix phpGH-10251: Assertion `(flag & (1<<3)) == 0' failed.
  Fix phpGH-9710: phpdbg memory leaks by option "-h"
  • Loading branch information
Girgias committed Jan 8, 2023
2 parents 092ad3e + e308dc0 commit 3b8327a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Zend/tests/gh10251.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
GH-10251 (Assertion `(flag & (1<<3)) == 0' failed.)
--FILE--
<?php
class A
{
function __set($o, $l)
{
$this->$p = $v;
}
}
$a = new A();
$pp = "";
$op = $pp & "";
// Bitwise operators on strings don't compute the hash.
// The code below previously assumed a hash was actually computed, leading to a crash.
$a->$op = 0;
echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $v in %s on line %d

Warning: Undefined variable $p in %s on line %d
Done
5 changes: 2 additions & 3 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,8 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe
if (EXPECTED(Z_TYPE_P(zv) == IS_STRING)) {
zend_string *str = Z_STR_P(zv);
if (EXPECTED(str == member) ||
/* "str" always has a pre-calculated hash value here */
(EXPECTED(ZSTR_H(str) == zend_string_hash_val(member)) &&
EXPECTED(zend_string_equal_content(str, member)))) {
/* str and member don't necessarily have a pre-calculated hash value here */
EXPECTED(zend_string_equal_content(str, member))) {
return &Z_PROPERTY_GUARD_P(zv);
} else if (EXPECTED(Z_PROPERTY_GUARD_P(zv) == 0)) {
zval_ptr_dtor_str(zv);
Expand Down
2 changes: 2 additions & 0 deletions sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,8 @@ int main(int argc, char **argv) /* {{{ */
get_zend_version()
);
}
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
php_module_shutdown();
sapi_deactivate();
sapi_shutdown();
php_ini_builder_deinit(&ini_builder);
Expand Down

0 comments on commit 3b8327a

Please sign in to comment.