yum-mirror/glslang

git clone https://git.yummers.dev/yum-mirror/glslang

Ashish Dhonepreprocessor: add macroExpandDepth guard to bound MacroExpand recursion6cbfdd64

main
1.1 KiB17 linesraw
1// Test: macroExpandDepth guard prevents stack overflow via
2// deeply nested function-like macro expansion.
3//
4// Without the macroExpandDepth counter (and macro->busy set before
5// PrescanMacroArg), F(F(F(...F(1)...))) causes MacroExpand to call
6// PrescanMacroArg which calls MacroExpand again for each nested F,
7// growing the C stack without bound until stack overflow.
8//
9// With the fix, expansion is terminated at depth 200 with an error.
10
11#version 450
12
13#define F(x) x
14
15int a = F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(F(1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
16
17void main() {}