mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 02:52:39 +08:00
Fix JS_EncodeStringToUTF8 memory leak
This commit is contained in:
@@ -1041,8 +1041,13 @@ void ScriptingCore::reportError(JSContext *cx, JSErrorReport *report, JS::Handle
|
||||
if (JS_GetProperty(cx, errObj, "stack", &stack) && stack.isString())
|
||||
{
|
||||
JS::RootedString jsstackStr(cx, stack.toString());
|
||||
stackStr = JS_EncodeStringToUTF8(cx, jsstackStr);
|
||||
CCLOGERROR("Stack: %s\n", stackStr.c_str());
|
||||
char *rawStr = JS_EncodeStringToUTF8(cx, jsstackStr);
|
||||
if (rawStr != nullptr)
|
||||
{
|
||||
stackStr = rawStr;
|
||||
JS_free(cx, rawStr);
|
||||
CCLOGERROR("Stack: %s\n", stackStr.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user