From 890e5a1eaddc151c0c49a061a54bbd6e68a45d43 Mon Sep 17 00:00:00 2001 From: songcongyi Date: Mon, 27 Sep 2021 13:06:10 +0800 Subject: [PATCH 1/2] fix codex Change-Id: I6c7ef0330d6d610d2b8f2992d4c0ec9e5bf27cf7 --- .../impl/quickjs/quickjs_native_engine.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/native_engine/impl/quickjs/quickjs_native_engine.cpp b/native_engine/impl/quickjs/quickjs_native_engine.cpp index cbaf76c98..96de2fe65 100644 --- a/native_engine/impl/quickjs/quickjs_native_engine.cpp +++ b/native_engine/impl/quickjs/quickjs_native_engine.cpp @@ -597,8 +597,21 @@ NativeValue* QuickJSNativeEngine::JSValueToNativeValue(QuickJSNativeEngine* engi void* QuickJSNativeEngine::CreateRuntime() { JSRuntime* runtime = JS_NewRuntime(); + if (runtime == nullptr) { + return nullptr; + } JSContext* context = JS_NewContext(runtime); - return reinterpret_cast(new QuickJSNativeEngine(runtime, context, this)); + if (context == nullptr) { + delete runtime; + return nullptr; + } + QuickJSNativeEngine qjsEngine = new QuickJSNativeEngine(runtime, context, this); + if (qjsEngine == nullptr) { + delete runtime; + delete context; + return nullptr; + } + return reinterpret_cast(qjsEngine); } bool QuickJSNativeEngine::CheckTransferList(JSValue transferList) -- Gitee From 150315ed2c6ba01cd28c1dcb5b369e859fc39a89 Mon Sep 17 00:00:00 2001 From: songcongyi Date: Mon, 27 Sep 2021 14:19:27 +0800 Subject: [PATCH 2/2] fix codex problem Change-Id: I90b5f2ab3064a1de2fd1240a75ac3660294717ac --- native_engine/impl/quickjs/quickjs_native_engine.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/native_engine/impl/quickjs/quickjs_native_engine.cpp b/native_engine/impl/quickjs/quickjs_native_engine.cpp index 96de2fe65..57cec6c83 100644 --- a/native_engine/impl/quickjs/quickjs_native_engine.cpp +++ b/native_engine/impl/quickjs/quickjs_native_engine.cpp @@ -602,13 +602,10 @@ void* QuickJSNativeEngine::CreateRuntime() } JSContext* context = JS_NewContext(runtime); if (context == nullptr) { - delete runtime; return nullptr; } - QuickJSNativeEngine qjsEngine = new QuickJSNativeEngine(runtime, context, this); + QuickJSNativeEngine* qjsEngine = new QuickJSNativeEngine(runtime, context, this); if (qjsEngine == nullptr) { - delete runtime; - delete context; return nullptr; } return reinterpret_cast(qjsEngine); -- Gitee