Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tools/clang/lib/Frontend/TextDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,10 @@ static void highlightRange(const CharSourceRange &R,
EndColNo = map.startOfPreviousColumn(EndColNo);

// If the start/end passed each other, then we are trying to highlight a
// range that just exists in whitespace, which must be some sort of other
// bug.
assert(StartColNo <= EndColNo && "Trying to highlight whitespace??");
// range that just exists in whitespace. This can happen with null bytes or
// other unusual characters in the source.
if (StartColNo > EndColNo)
return;
}

assert(StartColNo <= map.getSourceLine().size() && "Invalid range!");
Expand Down
7 changes: 7 additions & 0 deletions tools/clang/test/DXC/highlight-range-null-byte.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Regression test: dxc crashes on HLSL with embedded null bytes due to
; out-of-bounds access in highlightRange() (TextDiagnostic.cpp).

; RUN: python -c "import sys; sys.stdout.buffer.write(b'f(){a b int4\x00(1}')" > %t.hlsl
; RUN: not %dxc /T ps_6_0 %t.hlsl 2>&1 | FileCheck %s

; CHECK: error: HLSL requires a type specifier for all declarations
Comment thread
damyanp marked this conversation as resolved.
Outdated
Loading