diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-03-15 23:09:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-03-15 23:09:37 +0000 |
commit | 90d7fa12d0814bca69f95d2c4829391a6cb3935b (patch) | |
tree | 9a32c3bc60a887dcfda73b1f879c148825ef221d /clang/lib/Frontend/TextDiagnostic.cpp | |
parent | e7b849e4fb7e13a5be299b701d53896168345b15 (diff) | |
download | bcm5719-llvm-90d7fa12d0814bca69f95d2c4829391a6cb3935b.tar.gz bcm5719-llvm-90d7fa12d0814bca69f95d2c4829391a6cb3935b.zip |
Fix buffer underrun (invalid read) triggered during diagnostic rendering. The test would overflow when computing '0 - 1'.
I don't have a good testcase for this that does not depend on system headers.
It did not trigger with preprocessed output, and I had trouble reducing the example.
Fixes <rdar://problem/13324594>.
Thanks to Michael Greiner for reporting this issue.
llvm-svn: 177201
Diffstat (limited to 'clang/lib/Frontend/TextDiagnostic.cpp')
-rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index c9724612419..ca4ad60c524 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -958,7 +958,7 @@ static void highlightRange(const CharSourceRange &R, // Pick the last non-whitespace column. if (EndColNo > map.getSourceLine().size()) EndColNo = map.getSourceLine().size(); - while (EndColNo-1 && + while (EndColNo && (map.getSourceLine()[EndColNo-1] == ' ' || map.getSourceLine()[EndColNo-1] == '\t')) EndColNo = map.startOfPreviousColumn(EndColNo); |