From: Greg Clayton Date: Thu, 7 Feb 2013 03:38:34 +0000 (+0000) Subject: Fixed an bug found by running LLDB with the address sanitizer! We were accessing... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6cdd126e8a305facea26144230b1975f2076a31;p=platform%2Fupstream%2Fllvm.git Fixed an bug found by running LLDB with the address sanitizer! We were accessing one past the end of the buffer. llvm-svn: 174578 --- diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index 65b8165..8d3400d 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -569,11 +569,14 @@ SourceManager::File::CalculateLineOffsets (uint32_t line) register char curr_ch = *s; if (is_newline_char (curr_ch)) { - register char next_ch = s[1]; - if (is_newline_char (next_ch)) + if (s + 1 < end) { - if (curr_ch != next_ch) - ++s; + register char next_ch = s[1]; + if (is_newline_char (next_ch)) + { + if (curr_ch != next_ch) + ++s; + } } m_offsets.push_back(s + 1 - start); }