Skip to content

Commit fb6d55c

Browse files
committed
Fix infinite replace loop if a shader macro was defined to itself
One example affected preset is "martin + Se7enSlasher - pixies party (random texture edit).milk" Macros with an argument referencing itself may still be problematic, but is WAY less probable to pop up in the wild.
1 parent ab6adb2 commit fb6d55c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

vendor/hlslparser/src/HLSLParser.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,10 +3692,18 @@ HLSLMacro * HLSLParser::ProcessMacroFromIdentifier(std::string & sourcePreproces
36923692
if (m_macros[i]->argument == NULL)
36933693
{
36943694
// Macro without arguments
3695-
sourcePreprocessed.append("(");
3696-
sourcePreprocessed.append(m_macros[i]->value);
3697-
sourcePreprocessed.append(")");
3698-
addOriginalSource = false;
3695+
if (m_macros[i]->name == m_macros[i]->value)
3696+
{
3697+
// Macro name and value are identical (#define xyz xyz)
3698+
addOriginalSource = true;
3699+
}
3700+
else
3701+
{
3702+
sourcePreprocessed.append("(");
3703+
sourcePreprocessed.append(m_macros[i]->value);
3704+
sourcePreprocessed.append(")");
3705+
addOriginalSource = false;
3706+
}
36993707
}
37003708
else
37013709
{

0 commit comments

Comments
 (0)