mirror of
https://github.com/phpv8/v8js.git
synced 2025-01-07 05:51:51 +00:00
(un)protect myht outside of the loops, not tmp_ht inside
This commit is contained in:
parent
67bf51e30e
commit
6d7ea7cbf2
@ -167,11 +167,15 @@ extern struct _v8js_process_globals v8js_process_globals;
|
|||||||
void v8js_register_methods(v8::Local<v8::ObjectTemplate>, v8js_ctx *c);
|
void v8js_register_methods(v8::Local<v8::ObjectTemplate>, v8js_ctx *c);
|
||||||
|
|
||||||
#ifdef ZEND_HASH_INC_APPLY_COUNT
|
#ifdef ZEND_HASH_INC_APPLY_COUNT
|
||||||
|
#ifndef GC_PROTECT_RECURSION
|
||||||
# define GC_PROTECT_RECURSION(ht) ZEND_HASH_INC_APPLY_COUNT(ht)
|
# define GC_PROTECT_RECURSION(ht) ZEND_HASH_INC_APPLY_COUNT(ht)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef ZEND_HASH_DEC_APPLY_COUNT
|
#ifdef ZEND_HASH_DEC_APPLY_COUNT
|
||||||
|
#ifndef GC_UNPROTECT_RECURSION
|
||||||
# define GC_UNPROTECT_RECURSION(ht) ZEND_HASH_DEC_APPLY_COUNT(ht)
|
# define GC_UNPROTECT_RECURSION(ht) ZEND_HASH_DEC_APPLY_COUNT(ht)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PHP_V8JS_MACROS_H */
|
#endif /* PHP_V8JS_MACROS_H */
|
||||||
|
|
||||||
|
@ -84,21 +84,18 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
|
|||||||
{
|
{
|
||||||
zval *data;
|
zval *data;
|
||||||
ulong index = 0;
|
ulong index = 0;
|
||||||
HashTable *tmp_ht;
|
|
||||||
|
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||||
|
GC_PROTECT_RECURSION(myht);
|
||||||
|
}
|
||||||
|
|
||||||
ZEND_HASH_FOREACH_VAL(myht, data) {
|
ZEND_HASH_FOREACH_VAL(myht, data) {
|
||||||
tmp_ht = HASH_OF(data);
|
|
||||||
|
|
||||||
if (tmp_ht) {
|
|
||||||
GC_PROTECT_RECURSION(myht);
|
|
||||||
}
|
|
||||||
|
|
||||||
newarr->Set(index++, zval_to_v8js(data, isolate));
|
newarr->Set(index++, zval_to_v8js(data, isolate));
|
||||||
|
|
||||||
if (tmp_ht) {
|
|
||||||
GC_UNPROTECT_RECURSION(myht);
|
|
||||||
}
|
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
|
||||||
|
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||||
|
GC_UNPROTECT_RECURSION(myht);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newarr;
|
return newarr;
|
||||||
}
|
}
|
||||||
|
@ -955,21 +955,16 @@ static v8::Local<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zva
|
|||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
zval *data;
|
zval *data;
|
||||||
HashTable *tmp_ht;
|
|
||||||
|
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||||
|
GC_PROTECT_RECURSION(myht);
|
||||||
|
}
|
||||||
|
|
||||||
ZEND_HASH_FOREACH_KEY_VAL(myht, index, key, data) {
|
ZEND_HASH_FOREACH_KEY_VAL(myht, index, key, data) {
|
||||||
tmp_ht = HASH_OF(data);
|
|
||||||
|
|
||||||
if (tmp_ht) {
|
|
||||||
GC_PROTECT_RECURSION(tmp_ht);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
if (ZSTR_VAL(key)[0] == '\0' && Z_TYPE_P(value) == IS_OBJECT) {
|
if (ZSTR_VAL(key)[0] == '\0' && Z_TYPE_P(value) == IS_OBJECT) {
|
||||||
/* Skip protected and private members. */
|
/* Skip protected and private members. */
|
||||||
if (tmp_ht) {
|
|
||||||
GC_UNPROTECT_RECURSION(tmp_ht);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,10 +986,12 @@ static v8::Local<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zva
|
|||||||
newobj->Set(static_cast<uint32_t>(index), zval_to_v8js(data, isolate));
|
newobj->Set(static_cast<uint32_t>(index), zval_to_v8js(data, isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp_ht) {
|
|
||||||
GC_UNPROTECT_RECURSION(tmp_ht);
|
|
||||||
}
|
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
|
||||||
|
if (myht && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
|
||||||
|
GC_UNPROTECT_RECURSION(myht);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newobj;
|
return newobj;
|
||||||
|
Loading…
Reference in New Issue
Block a user