Fix crash editing shader if #include is the first line in the source

This commit is contained in:
baldurk
2015-03-29 18:11:12 +01:00
parent 9273a5bdb3
commit 8abb2f19cc
@@ -1904,12 +1904,12 @@ namespace renderdocui.Windows.PipelineState
{
// search back to ensure this is a valid #include (ie. not in a comment).
// Must only see whitespace before, then a newline.
int ws = offs-1;
int ws = Math.Max(0, offs-1);
while (ws >= 0 && (compileSource[ws] == ' ' || compileSource[ws] == '\t'))
ws--;
// not valid? jump to next.
if (compileSource[ws] != '\n')
if (ws > 0 && compileSource[ws] != '\n')
{
offs = compileSource.IndexOf("#include", offs + 1);
continue;