Fix out of bounds array access in DoEditBox

Introduced in 186206d40c
This commit is contained in:
def 2020-10-19 14:34:08 +02:00
parent c04621ea43
commit 8e6b9f017d

View file

@ -506,7 +506,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
if(str_length(aInputing))
{
float OffsetGlyphThis = OffsetGlyph;
if(StrLenDispl == s_AtIndex + Input()->GetEditingCursor() && pDisplayStr[StrLenDispl - 1] != ' ')
if(StrLenDispl >= 1 && StrLenDispl == s_AtIndex + Input()->GetEditingCursor() && pDisplayStr[StrLenDispl - 1] != ' ')
OffsetGlyphThis = 0;
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex + Input()->GetEditingCursor(), -1.0f);
Textbox.x += w + OffsetGlyphThis;
@ -521,7 +521,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
Graphics()->QuadsDrawTL(&CursorT, 1);
Graphics()->QuadsEnd();
}
if(StrLenDispl == s_AtIndex && pDisplayStr[StrLenDispl - 1] != ' ')
if(StrLenDispl >= 1 && StrLenDispl == s_AtIndex && pDisplayStr[StrLenDispl - 1] != ' ')
OffsetGlyph = 0;
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex, -1.0f);
Textbox = TmpTextBox;