summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoeren Moch <smoch@web.de>2022-06-18 09:30:50 +0200
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2022-06-19 15:52:25 +0200
commit89dc1ae97f018a261d789d1120c4fa11fdb813a1 (patch)
treed23a99a7cd3a4b5fdf8e3a40011c8fdf7494188f
parent2d61b79eba975cc001dd829d08d4b30ec31f8cbe (diff)
downloadskin-nopacity-89dc1ae97f018a261d789d1120c4fa11fdb813a1.tar.gz
skin-nopacity-89dc1ae97f018a261d789d1120c4fa11fdb813a1.tar.bz2
Avoid crash when selecting invisibile menu items
Items can be selected with number key presses in main and setup menus. When the selected item is not visible (scrolled out of the visible range) there is no need to update the item before closing the menu. Check for this condition to avoid crashing. Signed-off-by: Soeren Moch <smoch@web.de>
-rw-r--r--displaymenu.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/displaymenu.c b/displaymenu.c
index bcbd9ed..b83eae5 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -489,10 +489,15 @@ bool cNopacityDisplayMenu::SetItemRecording(const cRecording *Recording, int Ind
return true;
}
-
void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) {
- bool hasIcons = false;
- bool MainOrSetup = false;
+ if (Index < 0)
+ return;
+ if ((int)menuItems.size() <= Index) {
+ int maxitems = MaxItems();
+ if (maxitems <= Index)
+ return;
+ menuItems.resize(maxitems);
+ }
cString *strItems = new cString[MaxTabs];
int *tabItems = new int[2*MaxTabs];
for (int i=0; i<MaxTabs; i++) {
@@ -501,10 +506,10 @@ void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bo
tabItems[i+MaxTabs] = 0;
}
SplitItem(Text, strItems, tabItems);
- if ((int)menuItems.size() <= Index)
- menuItems.resize(MaxItems());
menuItems[Index].reset();
if (*Text != '\0') {
+ bool hasIcons = false;
+ bool MainOrSetup = false;
cNopacityMenuItem *item;
cPoint itemSize;
if (((MenuCategory() == mcMain)&&(config.GetValue("narrowMainMenu"))) || ((MenuCategory() == mcSetup)&&(config.GetValue("narrowSetupMenu")))){