From cc57375c3e9ad88c7728500cf6df5989b135a691 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 19 Jul 2024 16:19:13 +0800 Subject: [PATCH] fix(ios): turbo module type convert nullptr crash --- core/src/napi/jsc/jsc_ctx.cc | 3 --- ios/sdk/module/turbo/HippyOCTurboModule.mm | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/src/napi/jsc/jsc_ctx.cc b/core/src/napi/jsc/jsc_ctx.cc index 514899a3efc..1e02f0fd51e 100644 --- a/core/src/napi/jsc/jsc_ctx.cc +++ b/core/src/napi/jsc/jsc_ctx.cc @@ -467,9 +467,6 @@ std::shared_ptr JSCCtx::CreateObject(const std::unordered_map JSCCtx::CreateArray( size_t count, std::shared_ptr array[]) { - if (count <= 0) { - return nullptr; - } JSValueRef values[count]; // NOLINT(runtime/arrays) for (size_t i = 0; i < count; i++) { diff --git a/ios/sdk/module/turbo/HippyOCTurboModule.mm b/ios/sdk/module/turbo/HippyOCTurboModule.mm index 7ab518df0b8..678be5c950c 100644 --- a/ios/sdk/module/turbo/HippyOCTurboModule.mm +++ b/ios/sdk/module/turbo/HippyOCTurboModule.mm @@ -209,7 +209,7 @@ - (id)invokeObjCMethodWithName:(NSString *)methodName std::shared_ptr propRef = convertObjcObjectToCtxValue(jscCtx, propValue, module); std::shared_ptr ctx_value = std::static_pointer_cast(propRef); - JSValueRef valueRef = ctx_value->value_; + JSValueRef valueRef = ctx_value ? ctx_value->value_ : nullptr; JSStringRef propName = JSStringCreateWithCFString((__bridge CFStringRef)propertyName); JSValueRef jsError = NULL;