[Lldb-commits] [lldb] r192811 - prevent lui from crashing with small source files

Sriram Murali sriram87 at gmail.com
Wed Oct 16 09:48:43 PDT 2013


Author: sriram87
Date: Wed Oct 16 11:48:43 2013
New Revision: 192811

URL: http://llvm.org/viewvc/llvm-project?rev=192811&view=rev
Log:
prevent lui from crashing with small source files


Modified:
    lldb/trunk/utils/lui/sourcewin.py

Modified: lldb/trunk/utils/lui/sourcewin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/lui/sourcewin.py?rev=192811&r1=192810&r2=192811&view=diff
==============================================================================
--- lldb/trunk/utils/lui/sourcewin.py (original)
+++ lldb/trunk/utils/lui/sourcewin.py Wed Oct 16 11:48:43 2013
@@ -103,10 +103,11 @@ class SourceWin(cui.TitledWin):
 
       if self.viewline < 0:
         raise Exception("negative viewline: pc=%d viewline=%d" % (self.pc_line, self.viewline))
-      if self.viewline + self.height > len(self.content) + 1:
+      end = min(total_lines, self.height - 1)
+      if self.viewline + end > len(self.content) + 1:
         raise Exception("viewline too large: PC=%d viewline=%d (to %d of %d)" % (self.pc_line,
                                                                                  self.viewline,
-                                                                                 self.viewline + self.height - 1,
+                                                                                 self.viewline + end - 1,
                                                                                  total_lines))
 
   def refreshSource(self, process = None):
@@ -154,7 +155,8 @@ class SourceWin(cui.TitledWin):
     source = ""
     count = 1
     self.win.erase()
-    for i in range(self.viewline, self.viewline + self.height - 1):
+    end = min(len(content), self.height -1)
+    for i in range(self.viewline, self.viewline + end):
       if i > len(content) - 1:
         raise Exception("Out of range content (%d-%d of %d)" % (self.viewline,
                                                                 self.viewline + self.height - 1,





More information about the lldb-commits mailing list