From 8abb2f19ccfeab2485313845527fe88abadea73f Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 29 Mar 2015 18:11:12 +0100 Subject: [PATCH] Fix crash editing shader if #include is the first line in the source --- renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs index b6604d299..c269d1c49 100644 --- a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs @@ -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;