Skip to content

Commit 3b8327a

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-10251: Assertion `(flag & (1<<3)) == 0' failed. Fix GH-9710: phpdbg memory leaks by option "-h"
2 parents 092ad3e + e308dc0 commit 3b8327a

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Zend/tests/gh10251.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-10251 (Assertion `(flag & (1<<3)) == 0' failed.)
3+
--FILE--
4+
<?php
5+
class A
6+
{
7+
function __set($o, $l)
8+
{
9+
$this->$p = $v;
10+
}
11+
}
12+
$a = new A();
13+
$pp = "";
14+
$op = $pp & "";
15+
// Bitwise operators on strings don't compute the hash.
16+
// The code below previously assumed a hash was actually computed, leading to a crash.
17+
$a->$op = 0;
18+
echo "Done\n";
19+
?>
20+
--EXPECTF--
21+
Warning: Undefined variable $v in %s on line %d
22+
23+
Warning: Undefined variable $p in %s on line %d
24+
Done

Zend/zend_object_handlers.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,8 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe
553553
if (EXPECTED(Z_TYPE_P(zv) == IS_STRING)) {
554554
zend_string *str = Z_STR_P(zv);
555555
if (EXPECTED(str == member) ||
556-
/* "str" always has a pre-calculated hash value here */
557-
(EXPECTED(ZSTR_H(str) == zend_string_hash_val(member)) &&
558-
EXPECTED(zend_string_equal_content(str, member)))) {
556+
/* str and member don't necessarily have a pre-calculated hash value here */
557+
EXPECTED(zend_string_equal_content(str, member))) {
559558
return &Z_PROPERTY_GUARD_P(zv);
560559
} else if (EXPECTED(Z_PROPERTY_GUARD_P(zv) == 0)) {
561560
zval_ptr_dtor_str(zv);

sapi/phpdbg/phpdbg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,8 @@ int main(int argc, char **argv) /* {{{ */
13781378
get_zend_version()
13791379
);
13801380
}
1381+
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
1382+
php_module_shutdown();
13811383
sapi_deactivate();
13821384
sapi_shutdown();
13831385
php_ini_builder_deinit(&ini_builder);

0 commit comments

Comments
 (0)