fix std:clamp usage

We appear to consistently assume that clamp can be called with 0, size as
interval, but that actually results in a possible out of bounds access at the
upper end.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2025-01-10 15:44:49 -08:00 committed by Michael Keller
parent bbff369bf2
commit 5671a634a8
4 changed files with 10 additions and 10 deletions

View file

@ -41,7 +41,7 @@ void ChartListModel::initIcon(ChartSubType type, const char *name, int iconSize)
const QPixmap &ChartListModel::getIcon(ChartSubType type, bool warning) const
{
int idx = std::clamp((int)type, 0, (int)ChartSubType::Count);
int idx = std::clamp((int)type, 0, (int)ChartSubType::Count - 1);
return warning ? subTypeIcons[idx].warning : subTypeIcons[idx].normal;
}