diff --git a/native_engine/impl/quickjs/quickjs_native_engine.cpp b/native_engine/impl/quickjs/quickjs_native_engine.cpp index cbaf76c983c8312636b28fe286ffd9fd5d952d37..57cec6c839f9fe6f85fc78a3529899b2c1c99cb2 100644 --- a/native_engine/impl/quickjs/quickjs_native_engine.cpp +++ b/native_engine/impl/quickjs/quickjs_native_engine.cpp @@ -597,8 +597,18 @@ 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) { + return nullptr; + } + QuickJSNativeEngine* qjsEngine = new QuickJSNativeEngine(runtime, context, this); + if (qjsEngine == nullptr) { + return nullptr; + } + return reinterpret_cast(qjsEngine); } bool QuickJSNativeEngine::CheckTransferList(JSValue transferList)