Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 16650:fcb97d9a26cd stable
patch: fix segfault against unified diffs which start line is zero
Since 2b1ec74c961f, if a chunk starts with "@@ -0,1", oldstart turns into
a negative value. Because diffhelpers.testhunk() doesn't expect negative bstart,
it bypasses "alen > blen - bstart" condition and segfaults at
"PyList_GET_ITEM(b, i + bstart)".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 12 May 2012 16:10:01 +0900 |
parents | ed6a74312176 |
children | ea7bf1d49bce 6d42c797ca6e |
comparison
equal
deleted
inserted
replaced
16649:822e75386c16 | 16650:fcb97d9a26cd |
---|---|
1012 def fuzzit(self, fuzz, toponly): | 1012 def fuzzit(self, fuzz, toponly): |
1013 old, new, top = self._fuzzit(self.a, self.b, fuzz, toponly) | 1013 old, new, top = self._fuzzit(self.a, self.b, fuzz, toponly) |
1014 oldstart = self.starta + top | 1014 oldstart = self.starta + top |
1015 newstart = self.startb + top | 1015 newstart = self.startb + top |
1016 # zero length hunk ranges already have their start decremented | 1016 # zero length hunk ranges already have their start decremented |
1017 if self.lena: | 1017 if self.lena and oldstart > 0: |
1018 oldstart -= 1 | 1018 oldstart -= 1 |
1019 if self.lenb: | 1019 if self.lenb and newstart > 0: |
1020 newstart -= 1 | 1020 newstart -= 1 |
1021 return old, oldstart, new, newstart | 1021 return old, oldstart, new, newstart |
1022 | 1022 |
1023 class binhunk(object): | 1023 class binhunk(object): |
1024 'A binary patch file. Only understands literals so far.' | 1024 'A binary patch file. Only understands literals so far.' |