diff options
author | Sriram Murali <sriram87@gmail.com> | 2013-10-16 16:48:43 +0000 |
---|---|---|
committer | Sriram Murali <sriram87@gmail.com> | 2013-10-16 16:48:43 +0000 |
commit | 8a0386654a5af64229bad2a69a965e3c191958f2 (patch) | |
tree | 47f3866b4ea980ce638913dad675c6c516d2513c | |
parent | 678a9431fd3e3d0a554aa6736a14000ebe2ba7b0 (diff) | |
download | bcm5719-llvm-8a0386654a5af64229bad2a69a965e3c191958f2.tar.gz bcm5719-llvm-8a0386654a5af64229bad2a69a965e3c191958f2.zip |
prevent lui from crashing with small source files
llvm-svn: 192811
-rw-r--r-- | lldb/utils/lui/sourcewin.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lldb/utils/lui/sourcewin.py b/lldb/utils/lui/sourcewin.py index 055476bed32..a72d7a5eba6 100644 --- a/lldb/utils/lui/sourcewin.py +++ b/lldb/utils/lui/sourcewin.py @@ -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, |