Fix crash on displaying renamed file

A logic error in the method to pretty-print file renames could cause
a crash.  Ensure that we don't overrun the length of either the
old or new path when comparing.

Change-Id: I7f1006ec6cbdb723e77cb62b64414a960af04113
This commit is contained in:
James E. Blair 2015-06-05 14:55:23 -07:00
parent 1226ef8d57
commit 844ea40f8e
1 changed files with 2 additions and 2 deletions

View File

@ -474,13 +474,13 @@ class File(object):
return self.path
pre = []
post = []
for start in range(len(self.old_path)):
for start in range(min(len(self.old_path), len(self.path))):
if self.path[start] == self.old_path[start]:
pre.append(self.old_path[start])
else:
break
pre = ''.join(pre)
for end in range(1, len(self.old_path)-1):
for end in range(1, min(len(self.old_path), len(self.path))-1):
if self.path[0-end] == self.old_path[0-end]:
post.insert(0, self.old_path[0-end])
else: