Skip to content

Prevent operands from being released during comparison#19309

Closed
arnaud-lb wants to merge 1 commit into
php:PHP-8.3from
arnaud-lb:gh19305
Closed

Prevent operands from being released during comparison#19309
arnaud-lb wants to merge 1 commit into
php:PHP-8.3from
arnaud-lb:gh19305

Conversation

@arnaud-lb
Copy link
Copy Markdown
Member

Prevent operands from being released during comparison:

$a = [
    'foo' => 'test',
    'bar' => 2,
];
$b = [
    'foo' => new class {
        public function __toString() {
            global $a, $b;
            $a = $b = null;
            return '';
        }
    },
    'bar' => 2,
];

// Comparison of $a['foo'] and $b['foo'] calls __toString(), which releases
// both $a and $b.
var_dump($a > $b);

Fixes GH-19305

@arnaud-lb arnaud-lb marked this pull request as ready for review July 30, 2025 13:48
@arnaud-lb arnaud-lb requested a review from dstogov as a code owner July 30, 2025 13:48
Copy link
Copy Markdown
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct

@arnaud-lb arnaud-lb closed this in bc4b6ce Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants