comparison mercurial/diffhelpers.c @ 16651:9e40bc4c1bde stable

diffhelpers: harden testhunk
author Matt Mackall <mpm@selenic.com>
date Sat, 12 May 2012 10:02:47 +0200
parents a4e0908ce35b
children f1aa3010642f
comparison
equal deleted inserted replaced
16650:fcb97d9a26cd 16651:9e40bc4c1bde
133 133
134 if (!PyArg_ParseTuple(args, "OOl", &a, &b, &bstart)) 134 if (!PyArg_ParseTuple(args, "OOl", &a, &b, &bstart))
135 return NULL; 135 return NULL;
136 alen = PyList_Size(a); 136 alen = PyList_Size(a);
137 blen = PyList_Size(b); 137 blen = PyList_Size(b);
138 if (alen > blen - bstart) { 138 if (alen > blen - bstart || bstart < 0) {
139 return Py_BuildValue("l", -1); 139 return Py_BuildValue("l", -1);
140 } 140 }
141 for (i = 0; i < alen; i++) { 141 for (i = 0; i < alen; i++) {
142 sa = PyBytes_AsString(PyList_GET_ITEM(a, i)); 142 sa = PyBytes_AsString(PyList_GET_ITEM(a, i));
143 sb = PyBytes_AsString(PyList_GET_ITEM(b, i + bstart)); 143 sb = PyBytes_AsString(PyList_GET_ITEM(b, i + bstart));