mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +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)
|
if (matchIndex == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
long endIndex = startIndex;
|
long endIndex = matchIndex;
|
||||||
|
|
||||||
// Find end of layout declaration
|
// Find end of layout declaration
|
||||||
while (chars[endIndex] != ')' && chars[endIndex] != 0)
|
while (chars[endIndex] != ')' && chars[endIndex] != 0)
|
||||||
endIndex++;
|
endIndex++;
|
||||||
|
|
||||||
|
if (chars[endIndex] == ')')
|
||||||
|
endIndex++;
|
||||||
|
else if (chars[endIndex] == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
while (IsGlslWhitespace(chars[endIndex]))
|
while (IsGlslWhitespace(chars[endIndex]))
|
||||||
endIndex++;
|
endIndex++;
|
||||||
|
@ -221,7 +226,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
|
||||||
if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
|
if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
|
||||||
{
|
{
|
||||||
// yes - replace declaration with spaces
|
// yes - replace declaration with spaces
|
||||||
for (long i = startIndex; i < endIndex; i++)
|
for (long i = matchIndex; i < endIndex; i++)
|
||||||
chars[i] = ' ';
|
chars[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue