Skip to content

Fix crash in hooked iterator on properties array without dynamic properties#15394

Merged
iluuu1994 merged 1 commit into
php:masterfrom
iluuu1994:gh-15187
Aug 19, 2024
Merged

Fix crash in hooked iterator on properties array without dynamic properties#15394
iluuu1994 merged 1 commit into
php:masterfrom
iluuu1994:gh-15187

Conversation

@iluuu1994

Copy link
Copy Markdown
Member

Also fix incorrect usage of zend_read_property_ex().

Fixes GH-15187

@iluuu1994

iluuu1994 commented Aug 13, 2024

Copy link
Copy Markdown
Member Author

Actually, there's another issue:

class Test {
    public int $prop { set => $value; }
}

$test = new Test();
var_dump($test);
foreach ($test as $key => $value) {
    var_dump($key, $value);
}

This currently prints NULL, but the property should be skipped instead... I'll have a look tomorrow.

@iluuu1994

Copy link
Copy Markdown
Member Author

Ok, both issues should be fixed now. I changed the implementation to set data/key to null on reset/forward, and fetch the data (if it wasn't already) on valid/get_current_data. Fetching the data includes moving forward further if the data is unavailable, both for declared and dynamic properties.

@arnaud-lb arnaud-lb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me apart from one comment

Comment thread Zend/zend_property_hooks.c Outdated
@iluuu1994 iluuu1994 merged commit 60f87f2 into php:master Aug 19, 2024
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.

Segmentation fault (access illegal address) in zend allocator

2 participants