fix warning and ub (#3089)

This commit is contained in:
zxkmm
2026-03-14 00:51:15 +08:00
committed by GitHub
parent 5aecd4097e
commit b273165a0c
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -294,8 +294,8 @@ bool BtnGridView::set_highlighted(int32_t new_value, bool force_update) {
}
// Normalize offset to show maximum items when count decreased
if (offset + displayed_max > item_count && item_count > 0) {
if (item_count >= displayed_max) {
if (item_count > 0 && offset + displayed_max > static_cast<size_t>(item_count)) {
if (static_cast<size_t>(item_count) >= displayed_max) {
offset = item_count - displayed_max;
} else {
offset = 0;