From 526a576d89e24da988556dda831b877e79be4689 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 8 Sep 2019 09:52:16 +0300 Subject: [PATCH] - fixed VM abort when entering search menu https://forum.zdoom.org/viewtopic.php?t=65833 --- wadsrc/static/zscript/ui/menu/optionmenu.zs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wadsrc/static/zscript/ui/menu/optionmenu.zs b/wadsrc/static/zscript/ui/menu/optionmenu.zs index 63970bdf3c..cb47f77066 100644 --- a/wadsrc/static/zscript/ui/menu/optionmenu.zs +++ b/wadsrc/static/zscript/ui/menu/optionmenu.zs @@ -107,15 +107,19 @@ class OptionMenu : Menu mDesc = desc; DontDim = desc.mDontDim; - let last = mDesc.mItems[mDesc.mItems.size() - 1]; - bool lastIsText = (last is "OptionMenuItemStaticText"); - if (lastIsText) + let itemCount = mDesc.mItems.size(); + if (itemCount > 0) { - String text = last.mLabel; - bool lastIsSpace = (text == "" || text == " "); - if (lastIsSpace) + let last = mDesc.mItems[itemCount - 1]; + bool lastIsText = (last is "OptionMenuItemStaticText"); + if (lastIsText) { - mDesc.mItems.Pop(); + String text = last.mLabel; + bool lastIsSpace = (text == "" || text == " "); + if (lastIsSpace) + { + mDesc.mItems.Pop(); + } } }