# HG changeset patch # User Matt Mackall # Date 2012-05-12 08:02:47 # Node ID 9e40bc4c1bdee81f41be17c20174a2aa168f0db7 # Parent fcb97d9a26cd25c9751062fc73f2ee43c7eb0f28 diffhelpers: harden testhunk diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -135,7 +135,7 @@ testhunk(PyObject *self, PyObject *args) return NULL; alen = PyList_Size(a); blen = PyList_Size(b); - if (alen > blen - bstart) { + if (alen > blen - bstart || bstart < 0) { return Py_BuildValue("l", -1); } for (i = 0; i < alen; i++) {