Skip to content
Closed
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
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 @@ -535,9 +535,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