mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- fixed infinite loop and out-of-bound read in shader patcher
This commit is contained in:
parent
741d44d263
commit
87441dd0a1
1 changed files with 7 additions and 2 deletions
|
@ -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] = ' ';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue