From 67aa951fecd4f5e445a4b7e4dd7e1d0e4b757962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 27 Apr 2023 11:55:57 +0200 Subject: [PATCH] PopupMultiChoice: Don't range-check the int-value if being initialized from PopupMultiChoiceDynamic (valgrind) --- Common/UI/PopupScreens.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Common/UI/PopupScreens.h b/Common/UI/PopupScreens.h index d0babc3d56..f0270b9a10 100644 --- a/Common/UI/PopupScreens.h +++ b/Common/UI/PopupScreens.h @@ -204,10 +204,12 @@ public: I18NCat category, ScreenManager *screenManager, UI::LayoutParams *layoutParams = nullptr) : AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), choices_(choices), minVal_(minVal), numChoices_(numChoices), category_(category), screenManager_(screenManager) { - if (*value >= numChoices + minVal) - *value = numChoices + minVal - 1; - if (*value < minVal) - *value = minVal; + if (choices) { + if (*value >= numChoices + minVal) + *value = numChoices + minVal - 1; + if (*value < minVal) + *value = minVal; + } OnClick.Handle(this, &PopupMultiChoice::HandleClick); UpdateText(); }