0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 15:11:53 +00:00

Merge pull request #506 from redbullmarky/php8

Segfault fix when using empty()
This commit is contained in:
Stefan Siegl 2023-02-19 18:58:14 +01:00 committed by GitHub
commit eb61c4ddcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

20
tests/issue_504_001.phpt Normal file
View File

@ -0,0 +1,20 @@
--TEST--
Test empty() : Segmentation fault caused by 'empty' check on a V8Function object
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$v = new \V8Js();
$r = $v->executeString('
a = {
main: function() {}
};
', null, V8Js::FLAG_FORCE_ARRAY | V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS);
if (!empty($r['main'])) {
echo 'Ok' . PHP_EOL;
}
?>
--EXPECTF--
Ok

View File

@ -933,7 +933,6 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
/* V8<Object|Function> handlers */ /* V8<Object|Function> handlers */
memcpy(&v8js_v8object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&v8js_v8object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
v8js_v8object_handlers.clone_obj = NULL; v8js_v8object_handlers.clone_obj = NULL;
v8js_v8object_handlers.cast_object = NULL;
v8js_v8object_handlers.get_property_ptr_ptr = v8js_v8object_get_property_ptr_ptr; v8js_v8object_handlers.get_property_ptr_ptr = v8js_v8object_get_property_ptr_ptr;
v8js_v8object_handlers.has_property = v8js_v8object_has_property; v8js_v8object_handlers.has_property = v8js_v8object_has_property;
v8js_v8object_handlers.read_property = v8js_v8object_read_property; v8js_v8object_handlers.read_property = v8js_v8object_read_property;