From 1e25cc8788393a18a1cf43626e43238eed6ec5b0 Mon Sep 17 00:00:00 2001 From: Mark Grainger Date: Sat, 18 Feb 2023 14:58:43 +0000 Subject: [PATCH 1/2] segfault fix when checking with empty --- v8js_v8object_class.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/v8js_v8object_class.cc b/v8js_v8object_class.cc index ff1495c..332b9a2 100644 --- a/v8js_v8object_class.cc +++ b/v8js_v8object_class.cc @@ -916,7 +916,6 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */ /* V8 handlers */ memcpy(&v8js_v8object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); 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.has_property = v8js_v8object_has_property; v8js_v8object_handlers.read_property = v8js_v8object_read_property; From 79a46804dc850268833d39ebf4f1e3efdaca8b80 Mon Sep 17 00:00:00 2001 From: Mark Grainger Date: Sat, 18 Feb 2023 15:12:29 +0000 Subject: [PATCH 2/2] empty() test --- tests/issue_504_001.phpt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/issue_504_001.phpt diff --git a/tests/issue_504_001.phpt b/tests/issue_504_001.phpt new file mode 100644 index 0000000..79d9658 --- /dev/null +++ b/tests/issue_504_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test empty() : Segmentation fault caused by 'empty' check on a V8Function object +--SKIPIF-- + +--FILE-- +executeString(' + a = { + main: function() {} + }; +', null, V8Js::FLAG_FORCE_ARRAY | V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); + +if (!empty($r['main'])) { + echo 'Ok' . PHP_EOL; +} +?> +--EXPECTF-- +Ok +