Skip to content

Commit cd909f6

Browse files
committed
add safety checks
1 parent 1d90563 commit cd909f6

File tree

1 file changed

+7
-3
lines changed
  • test-app/runtime/src/main/cpp/runtime/console

1 file changed

+7
-3
lines changed

test-app/runtime/src/main/cpp/runtime/console/Console.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ std::string transformJSObject(napi_env env, napi_value object) {
8787
napi_is_error(env, object, &is_error);
8888
if (is_error) {
8989
napi_value stack;
90-
napi_get_named_property(env, object, "stack", &stack);
91-
auto stack_value = ArgConverter::ConvertToString(env, stack);
92-
value += "\n" + stack_value;
90+
napi_status status = napi_get_named_property(env, object, "stack", &stack);
91+
if (status == napi_ok && !napi_util::is_null_or_undefined(env, stack)) {
92+
auto stack_value = ArgConverter::ConvertToString(env, stack);
93+
if (!stack_value.empty() && value.find(stack_value) == std::string::npos) {
94+
value += "\n" + stack_value;
95+
}
96+
}
9397
}
9498

9599
auto hasCustomToStringImplementation = value.find("[object Object]") == std::string::npos;

0 commit comments

Comments
 (0)