[Lldb-commits] [lldb] r174578 - Fixed an bug found by running LLDB with the address sanitizer! We were accessing one past the end of the buffer.

Greg Clayton gclayton at apple.com
Wed Feb 6 19:38:34 PST 2013


Author: gclayton
Date: Wed Feb  6 21:38:34 2013
New Revision: 174578

URL: http://llvm.org/viewvc/llvm-project?rev=174578&view=rev
Log:
Fixed an bug found by running LLDB with the address sanitizer! We were accessing one past the end of the buffer.

Modified:
    lldb/trunk/source/Core/SourceManager.cpp

Modified: lldb/trunk/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=174578&r1=174577&r2=174578&view=diff
==============================================================================
--- lldb/trunk/source/Core/SourceManager.cpp (original)
+++ lldb/trunk/source/Core/SourceManager.cpp Wed Feb  6 21:38:34 2013
@@ -569,11 +569,14 @@ SourceManager::File::CalculateLineOffset
                     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);
                     }





More information about the lldb-commits mailing list