diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-21 14:18:28 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-21 14:18:28 +0000 |
commit | d41ee2d2af81f94d51d25cf82d56309fe51a930d (patch) | |
tree | 4b4ef55ecb4f5b21ca76ed4ade1a0af9c38bf30a | |
parent | d5e782b010927328d1acde9940552c3f2dbff3e4 (diff) | |
download | bcm5719-llvm-d41ee2d2af81f94d51d25cf82d56309fe51a930d.tar.gz bcm5719-llvm-d41ee2d2af81f94d51d25cf82d56309fe51a930d.zip |
Fix bug discovered by valgrind.
When trying to merge lines, we should not touch lines that are invalid,
as we don't know how long they might be.
llvm-svn: 173043
-rw-r--r-- | clang/lib/Format/Format.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d234006a25a..a4de062fbfd 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1716,7 +1716,7 @@ private: return; Limit -= I->Last->TotalLength + 1; // One space. - if (I + 1 == E) + if (I + 1 == E || (I + 1)->Type == LT_Invalid) return; if (I->Last->is(tok::l_brace)) { @@ -1770,7 +1770,8 @@ private: std::vector<AnnotatedLine>::iterator E, unsigned Limit){ // Check that we still have three lines and they fit into the limit. - if (I + 2 == E || !nextTwoLinesFitInto(I, Limit)) + if (I + 2 == E || (I + 2)->Type == LT_Invalid || + !nextTwoLinesFitInto(I, Limit)) return; // First, check that the current line allows merging. This is the case if |