Make sure source strings are terminated (#1641)

* Make sure source strings are terminated

The source strings may or may not have a null terminator. We need to
make sure we add one before outputting the source strings as we iterate
over the c-str looking for the null terminator.

* Review feedback
This commit is contained in:
dan sinclair 2019-01-07 11:47:37 -05:00 committed by John Kessenich
parent 6eab476e5a
commit e96fa717d3
2 changed files with 6 additions and 3 deletions

View file

@ -879,8 +879,11 @@ bool ProcessDeferred(
intermediate.setHlslOffsets();
if (messages & EShMsgDebugInfo) {
intermediate.setSourceFile(names[numPre]);
for (int s = 0; s < numStrings; ++s)
intermediate.addSourceText(strings[numPre + s]);
for (int s = 0; s < numStrings; ++s) {
// The string may not be null-terminated, so make sure we provide
// the length along with the string.
intermediate.addSourceText(strings[numPre + s], lengths[numPre + s]);
}
}
SetupBuiltinSymbolTable(version, profile, spvVersion, source);