Skip to content

Commit

Permalink
Fixed GetContainedCharacterIndexFromPos accessing invalid index ^& crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Box-Coder committed May 5, 2023
1 parent 8217d29 commit bec0af3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Src/ssGUI/GUIObjectClasses/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,9 @@ namespace ssGUI
//TODO: Add max search iterations
while (true)
{
if(endIndex < startIndex)
return -1;

//Check start and end index are valid
while (!CharactersRenderInfos[startIndex].Valid && startIndex < CharactersRenderInfos.size())
{
Expand Down Expand Up @@ -1889,6 +1892,9 @@ namespace ssGUI
return midIndex;
}

if(endIndex <= startIndex)
return -1;

ssGUI::CharacterRenderInfo& startInfo = CharactersRenderInfos[startIndex];
ssGUI::CharacterRenderInfo& endInfo = CharactersRenderInfos[endIndex];

Expand Down

0 comments on commit bec0af3

Please sign in to comment.