mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
bbff369bf2
commit
5671a634a8
4 changed files with 10 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue