From 844ea40f8e70b1b2731a3eeb12e9876637a3a5d7 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 5 Jun 2015 14:55:23 -0700 Subject: [PATCH] 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 --- gertty/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gertty/db.py b/gertty/db.py index dedd317..6fec500 100644 --- a/gertty/db.py +++ b/gertty/db.py @@ -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: