Commit 8bf4087
preprocessor: guard against column underflow in DoPreprocessing
When DoPreprocessing::operator() encounters a new line, it attempts to
emit leading whitespace via:
outputBuffer += std::string(ppToken.loc.column - 1, ' ');
If ppToken.loc.column is 0 (which can occur after a backslash-newline
continuation at the end of input, e.g. 'GL_EXT_shader_image_load_formatted\\n'
with GLSL version 450 and EShMsgDefault), the subtraction underflows to
SIZE_MAX, causing std::string(SIZE_MAX, ' ') to throw std::length_error.
Since the exception is uncaught, std::terminate() is called and the process
aborts.
Fix: add a column > 0 guard before the subtraction.
Reproducer (36 bytes, pure ASCII):
GL_EXT_shader_image_load_formatted\\n
→ TShader::preprocess(version=450, ENoProfile, EShMsgDefault)
→ terminate called after throwing 'std::length_error': basic_string::_M_create1 parent a163b7f commit 8bf4087
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1178 | 1178 | | |
1179 | 1179 | | |
1180 | 1180 | | |
1181 | | - | |
| 1181 | + | |
| 1182 | + | |
1182 | 1183 | | |
1183 | 1184 | | |
1184 | 1185 | | |
| |||
0 commit comments