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

break recursion immediately on PHP <= 7.2 as well

This commit is contained in:
Stefan Siegl 2018-07-13 15:41:41 +02:00
parent 42e907c31e
commit 90b6b31f06
No known key found for this signature in database
GPG Key ID: 73942AF5642F3DDA
2 changed files with 34 additions and 6 deletions

View 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===

View File

@ -71,10 +71,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
/* Prevent recursion */ /* Prevent recursion */
#if PHP_VERSION_ID >= 70300 #if PHP_VERSION_ID >= 70300
if (myht && GC_IS_RECURSIVE(myht)) { if (myht && GC_IS_RECURSIVE(myht))
#else #else
if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 1) { if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 0)
#endif #endif
{
return V8JS_NULL; return V8JS_NULL;
} }
@ -86,10 +87,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
ulong index = 0; ulong index = 0;
#if PHP_VERSION_ID >= 70300 #if PHP_VERSION_ID >= 70300
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) { if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE))
#else #else
if (myht) { if (myht)
#endif #endif
{
GC_PROTECT_RECURSION(myht); 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(); } ZEND_HASH_FOREACH_END();
#if PHP_VERSION_ID >= 70300 #if PHP_VERSION_ID >= 70300
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) { if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE))
#else #else
if (myht) { if (myht)
#endif #endif
{
GC_UNPROTECT_RECURSION(myht); GC_UNPROTECT_RECURSION(myht);
} }
} }