php / php-src

The PHP Interpreter
https://www.php.net
Other
38.1k stars 7.74k forks source link

Segmentation fault in Zend/zend_types.h #15906

Open YuanchengJiang opened 1 month ago

YuanchengJiang commented 1 month ago

Description

The following code:

<?php
class Test {
private $prop {
set { echo __METHOD__, "\n"; }
}
}
$test = new Test;
$fusion = $test;
foreach($fusion as $value) {
}

Resulted in this output:

/php-src/Zend/zend_types.h:650:13: runtime error: member access within null pointer of type 'const zval' (aka 'const struct _zval_struct')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/Zend/zend_types.h:650:13

https://3v4l.org/BMg1A/rfc#vgit.master

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

cmb69 commented 1 month ago

https://github.com/php/php-src/blob/b438e2b1ed9b0f5a185a0385eef4d829005356a2/Zend/zend_property_hooks.c#L123-L124

I think we need to handle zend_hash_get_current_data(properties) returning NULL here.