Skip to content

Commit f1ebb86

Browse files
committed
修复错误 toArray 导致 format 抛出错误
1 parent de5e5b3 commit f1ebb86

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fibjs/src/util/util.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,13 @@ exlib::string json_format(v8::Local<v8::Value> obj)
184184
v8::Local<v8::Value> toArray = obj->Get(isolate->NewFromUtf8("toArray"));
185185
if (!IsEmpty(toArray) && toArray->IsFunction())
186186
{
187-
v = v8::Local<v8::Function>::Cast(toArray)->Call(obj, 0, NULL);
188-
obj = v->ToObject();
187+
TryCatch try_catch;
188+
v8::Local<v8::Value> v1 = v8::Local<v8::Function>::Cast(toArray)->Call(obj, 0, NULL);
189+
if (!IsEmpty(v1) && v1->IsObject())
190+
{
191+
v = v1;
192+
obj = v1->ToObject();
193+
}
189194
}
190195

191196
int32_t sz = (int32_t)stk.size();

0 commit comments

Comments
 (0)