diff --git a/frameworks/bridge/arkts_frontend/ani_water_flow_module.cpp b/frameworks/bridge/arkts_frontend/ani_water_flow_module.cpp index a5dcee403431cd09efcce87d5f530aa8f0979157..f6c46b7e1c4a14ee39632930ab7761d19870f6dc 100644 --- a/frameworks/bridge/arkts_frontend/ani_water_flow_module.cpp +++ b/frameworks/bridge/arkts_frontend/ani_water_flow_module.cpp @@ -269,6 +269,7 @@ void AniWaterFlowModule::ParseWaterFlowSections(ani_env* env, ani_ref sections, } ani_size changeArrayLength; if (env->Array_GetLength(static_cast(changeArray), &changeArrayLength) != ANI_OK) { + return; } ani_class sectionChangeInfo; @@ -281,7 +282,8 @@ void AniWaterFlowModule::ParseWaterFlowSections(ani_env* env, ani_ref sections, return; } - for (int32_t i = 0; i < changeArrayLength; i++) { + int32_t changeLength = static_cast(changeArrayLength); + for (int32_t i = 0; i < changeLength; i++) { ani_ref change; if (env->Array_Get_Ref(static_cast(changeArray), i, &change) != ANI_OK) { continue; diff --git a/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp b/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp index 8f9a586ce1026e26866fcbd8ce6534a7ba24e9ee..696ba00b0fd402c54fe336603f696dd77f4b3721 100644 --- a/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp +++ b/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp @@ -464,7 +464,8 @@ float WaterFlowSegmentedLayout::SolveJumpOffset(const WaterFlowLayoutInfo::ItemI void WaterFlowSegmentedLayout::MeasureToTarget(int32_t targetIdx, std::optional cacheDeadline, bool force) { targetIdx = std::min(targetIdx, info_->GetChildrenCount() - 1); - for (int32_t i = static_cast(info_->itemInfos_.size()); i <= targetIdx; ++i) { + const int32_t curSize = static_cast(info_->itemInfos_.size()); + for (int32_t i = curSize; i <= targetIdx; ++i) { int32_t seg = info_->GetSegment(i); auto position = WaterFlowLayoutUtils::GetItemPosition(info_, i, mainGaps_[seg]); float itemHeight = WaterFlowLayoutUtils::GetUserDefHeight(sections_, seg, i);