- fixed infinite loop and out-of-bound read in shader patcher

This commit is contained in:
alexey.lysiuk 2019-03-05 13:06:39 +02:00
parent 741d44d263
commit 87441dd0a1

View file

@ -197,12 +197,17 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
if (matchIndex == -1)
break;
long endIndex = startIndex;
long endIndex = matchIndex;
// Find end of layout declaration
while (chars[endIndex] != ')' && chars[endIndex] != 0)
endIndex++;
if (chars[endIndex] == ')')
endIndex++;
else if (chars[endIndex] == 0)
break;
// Skip whitespace
while (IsGlslWhitespace(chars[endIndex]))
endIndex++;
@ -221,7 +226,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
{
// yes - replace declaration with spaces
for (long i = startIndex; i < endIndex; i++)
for (long i = matchIndex; i < endIndex; i++)
chars[i] = ' ';
}