From 25863a1a52b36b6f9d02d4bcc987aff9fb50a82c Mon Sep 17 00:00:00 2001 From: liuyics15 <1179805842@qq.com> Date: Mon, 8 Sep 2025 15:33:43 +0800 Subject: [PATCH] fix dt fuzz errors Signed-off-by: liuyics15 <1179805842@qq.com> (cherry picked from commit cc4fca54db307ed6fadb30f2ced54e40a83cf986) Signed-off-by: liuyics15 <1179805842@qq.com> Change-Id: Ie39f46b169c91d54ceff7349556f02d92dbb9f1c Signed-off-by: liuyics15 <1179805842@qq.com> --- .../inner_api/cjffi/ark_interop/ark_interop_bigint.cpp | 1 + interfaces/inner_api/cjffi/ark_interop/ark_interop_napi.cpp | 6 ++++++ .../inner_api/cjffi/ark_interop/ark_interop_object.cpp | 2 ++ .../inner_api/cjffi/ark_interop/ark_interop_string.cpp | 2 ++ .../inner_api/cjffi/ark_interop/ark_interop_symbol.cpp | 3 ++- test/unittest/cj_native/test_ark_interop.cpp | 2 +- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/cjffi/ark_interop/ark_interop_bigint.cpp b/interfaces/inner_api/cjffi/ark_interop/ark_interop_bigint.cpp index cf8a58eb3..6dd6c9569 100644 --- a/interfaces/inner_api/cjffi/ark_interop/ark_interop_bigint.cpp +++ b/interfaces/inner_api/cjffi/ark_interop/ark_interop_bigint.cpp @@ -81,6 +81,7 @@ ARKTS_Value ARKTS_CreateBigIntWithBytes(ARKTS_Env env, bool isNegative, int64_t bool ARKTS_IsBigInt(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto tag = BIT_CAST(value, panda::JSValueRef); if (!tag.IsHeapObject()) { return false; diff --git a/interfaces/inner_api/cjffi/ark_interop/ark_interop_napi.cpp b/interfaces/inner_api/cjffi/ark_interop/ark_interop_napi.cpp index 749b81677..cd46d8909 100644 --- a/interfaces/inner_api/cjffi/ark_interop/ark_interop_napi.cpp +++ b/interfaces/inner_api/cjffi/ark_interop/ark_interop_napi.cpp @@ -291,6 +291,8 @@ ARKTS_Value ARKTS_CreateFunc(ARKTS_Env env, int64_t lambdaId) bool ARKTS_IsClass(ARKTS_Env env, ARKTS_Value value) { + ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto tag = BIT_CAST(value, JSValueRef); if (!tag.IsHeapObject()) { return false; @@ -468,6 +470,7 @@ ARKTS_Value ARKTS_GetElement(ARKTS_Env env, ARKTS_Value array, uint32_t index) bool ARKTS_IsArray(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is NULL"); + ARKTS_ASSERT_F(value, "value is null"); auto v = BIT_CAST(value, JSValueRef); if (!v.IsHeapObject()) { return false; @@ -502,6 +505,7 @@ ARKTS_Value ARKTS_CreateArrayBufferWithData(ARKTS_Env env, void* buffer, int32_t bool ARKTS_IsArrayBuffer(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto tag = BIT_CAST(value, JSValueRef); if (!tag.IsHeapObject()) { return false; @@ -576,6 +580,7 @@ ARKTS_Value ARKTS_CreateExternal(ARKTS_Env env, void* data) bool ARKTS_IsExternal(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto prime = BIT_CAST(value, JSValueRef); if (!prime.IsHeapObject()) { return false; @@ -643,6 +648,7 @@ void ARKTS_PromiseCapabilityReject(ARKTS_Env env, ARKTS_Promise prom, ARKTS_Valu bool ARKTS_IsPromise(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto v = BIT_CAST(value, JSValueRef); if (!v.IsHeapObject()) { return false; diff --git a/interfaces/inner_api/cjffi/ark_interop/ark_interop_object.cpp b/interfaces/inner_api/cjffi/ark_interop/ark_interop_object.cpp index 50c3e9a10..db3ec185f 100644 --- a/interfaces/inner_api/cjffi/ark_interop/ark_interop_object.cpp +++ b/interfaces/inner_api/cjffi/ark_interop/ark_interop_object.cpp @@ -46,6 +46,7 @@ ARKTS_Value ARKTS_CreateObject(ARKTS_Env env) bool ARKTS_IsHeapObject(ARKTS_Value value) { + ARKTS_ASSERT_F(value, "value is null"); auto v = BIT_CAST(value, JSValueRef); return v.IsHeapObject(); } @@ -53,6 +54,7 @@ bool ARKTS_IsHeapObject(ARKTS_Value value) bool ARKTS_IsObject(ARKTS_Env env, ARKTS_Value value) { ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto v = BIT_CAST(value, JSValueRef); if (!v.IsHeapObject()) { return false; diff --git a/interfaces/inner_api/cjffi/ark_interop/ark_interop_string.cpp b/interfaces/inner_api/cjffi/ark_interop/ark_interop_string.cpp index ed36898e7..ca23b53ef 100644 --- a/interfaces/inner_api/cjffi/ark_interop/ark_interop_string.cpp +++ b/interfaces/inner_api/cjffi/ark_interop/ark_interop_string.cpp @@ -44,6 +44,8 @@ ARKTS_Value ARKTS_CreateUtf8(ARKTS_Env env, const char* value, int32_t size) bool ARKTS_IsString(ARKTS_Env env, ARKTS_Value value) { + ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto v = BIT_CAST(value, JSValueRef); if (v.IsHole() || !v.IsHeapObject()) { return false; diff --git a/interfaces/inner_api/cjffi/ark_interop/ark_interop_symbol.cpp b/interfaces/inner_api/cjffi/ark_interop/ark_interop_symbol.cpp index 707581c37..5c65e8f2d 100644 --- a/interfaces/inner_api/cjffi/ark_interop/ark_interop_symbol.cpp +++ b/interfaces/inner_api/cjffi/ark_interop/ark_interop_symbol.cpp @@ -38,6 +38,8 @@ ARKTS_Value ARKTS_CreateSymbol(ARKTS_Env env, const char* description, int32_t l bool ARKTS_IsSymbol(ARKTS_Env env, ARKTS_Value value) { + ARKTS_ASSERT_F(env, "env is null"); + ARKTS_ASSERT_F(value, "value is null"); auto tag = BIT_CAST(value, JSValueRef); if (!tag.IsHeapObject()) { return false; @@ -49,7 +51,6 @@ bool ARKTS_IsSymbol(ARKTS_Env env, ARKTS_Value value) const char* ARKTS_GetSymbolDesc(ARKTS_Env env, ARKTS_Value value) { - ARKTS_ASSERT_P(env, "env is null"); ARKTS_ASSERT_P(ARKTS_IsSymbol(env, value), "value is not a symbol"); auto vm = P_CAST(env, EcmaVM*); diff --git a/test/unittest/cj_native/test_ark_interop.cpp b/test/unittest/cj_native/test_ark_interop.cpp index b1633eb15..e3b971553 100644 --- a/test/unittest/cj_native/test_ark_interop.cpp +++ b/test/unittest/cj_native/test_ark_interop.cpp @@ -1436,7 +1436,7 @@ TEST_F(ArkInteropTest, GlobalRelease) TEST_F(ArkInteropTest, GlobalReleaseSync) { - MockContext local(ARKTS_CreateEngineWithNewThread()); + MockContext local; auto env = local.GetEnv(); int loops = 10; auto totalRepeat = 500000; -- Gitee