From e2932253947a1aeaccc260781bf076cc92c46666 Mon Sep 17 00:00:00 2001 From: lanshouren Date: Wed, 19 Jun 2024 18:01:52 +0800 Subject: [PATCH] [ContentSlot]fix crash caused by null pointer dereference Signed-off-by: lanshouren Change-Id: I63f83864bd7e664c4798b7fa380c457a5fd8748b --- interfaces/native/node/node_model.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interfaces/native/node/node_model.cpp b/interfaces/native/node/node_model.cpp index f4a33d260c5..fbeae06d404 100644 --- a/interfaces/native/node/node_model.cpp +++ b/interfaces/native/node/node_model.cpp @@ -672,6 +672,7 @@ int32_t OH_ArkUI_NodeContent_AddNode(ArkUI_NodeContentHandle content, ArkUI_Node { auto* impl = OHOS::Ace::NodeModel::GetFullImpl(); CHECK_NULL_RETURN(impl, OHOS::Ace::ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND); + CHECK_NULL_RETURN(node, OHOS::Ace::ERROR_CODE_PARAM_INVALID); return impl->getNodeModifiers()->getNodeContentModifier()->addChild( reinterpret_cast(content), node->uiNodeHandle); } @@ -680,6 +681,7 @@ int32_t OH_ArkUI_NodeContent_InsertNode(ArkUI_NodeContentHandle content, ArkUI_N { auto* impl = OHOS::Ace::NodeModel::GetFullImpl(); CHECK_NULL_RETURN(impl, OHOS::Ace::ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND); + CHECK_NULL_RETURN(node, OHOS::Ace::ERROR_CODE_PARAM_INVALID); return impl->getNodeModifiers()->getNodeContentModifier()->insertChild( reinterpret_cast(content), node->uiNodeHandle, position); } @@ -688,6 +690,7 @@ int32_t OH_ArkUI_NodeContent_RemoveNode(ArkUI_NodeContentHandle content, ArkUI_N { auto* impl = OHOS::Ace::NodeModel::GetFullImpl(); CHECK_NULL_RETURN(impl, OHOS::Ace::ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND); + CHECK_NULL_RETURN(node, OHOS::Ace::ERROR_CODE_PARAM_INVALID); return impl->getNodeModifiers()->getNodeContentModifier()->removeChild( reinterpret_cast(content), node->uiNodeHandle); }