mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 09:21:52 +00:00
break recursion immediately on PHP <= 7.2 as well
This commit is contained in:
parent
42e907c31e
commit
90b6b31f06
25
tests/array_recursive.phpt
Normal file
25
tests/array_recursive.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Test V8::executeString() : export of recursive array
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = [];
|
||||
$a[] = &$a;
|
||||
$a[] = 23;
|
||||
|
||||
$v8 = new V8Js();
|
||||
$v8->foo = $a;
|
||||
$v8->executeString('var_dump(PHP.foo);');
|
||||
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0] =>
|
||||
NULL
|
||||
[1] =>
|
||||
int(23)
|
||||
}
|
||||
===EOF===
|
@ -71,10 +71,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
|
||||
|
||||
/* Prevent recursion */
|
||||
#if PHP_VERSION_ID >= 70300
|
||||
if (myht && GC_IS_RECURSIVE(myht)) {
|
||||
if (myht && GC_IS_RECURSIVE(myht))
|
||||
#else
|
||||
if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 1) {
|
||||
if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 0)
|
||||
#endif
|
||||
{
|
||||
return V8JS_NULL;
|
||||
}
|
||||
|
||||
@ -86,10 +87,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
|
||||
ulong index = 0;
|
||||
|
||||
#if PHP_VERSION_ID >= 70300
|
||||
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE))
|
||||
#else
|
||||
if (myht) {
|
||||
if (myht)
|
||||
#endif
|
||||
{
|
||||
GC_PROTECT_RECURSION(myht);
|
||||
}
|
||||
|
||||
@ -98,10 +100,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
#if PHP_VERSION_ID >= 70300
|
||||
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE))
|
||||
#else
|
||||
if (myht) {
|
||||
if (myht)
|
||||
#endif
|
||||
{
|
||||
GC_UNPROTECT_RECURSION(myht);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user