diff options
| author | Yujon Pradhananga <139200034+Yujonpradhananga@users.noreply.github.com> | 2026-03-02 00:04:02 +0545 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-01 18:19:02 +0000 |
| commit | 6ebafcf1073d5d0fd89e668ae2588f4d525ea403 (patch) | |
| tree | dc2d09fff42de6167fc6e48bda623abdc2f46b29 /src/layout/algorithm/tiled | |
| parent | 8ad96a95d62b16d5c9a141ad5a37b51388a68aef (diff) | |
layout/scrolling: fix size_t underflow in idxForHeight (#13465)
Diffstat (limited to 'src/layout/algorithm/tiled')
| -rw-r--r-- | src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index d9382c72..c7fe6078 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -190,10 +190,12 @@ size_t SColumnData::idx(SP<ITarget> t) { } size_t SColumnData::idxForHeight(float y) { + if (targetDatas.empty()) + return 0; for (size_t i = 0; i < targetDatas.size(); ++i) { if (targetDatas[i]->target->position().y < y) continue; - return i - 1; + return i == 0 ? 0 : i - 1; } return targetDatas.size() - 1; } |
