Mercurial > hg-stable
diff mercurial/parsers.c @ 26017:44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Now it raises IndexError instead of SEGV for 'wdir()' as it was before.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 13 Aug 2015 18:38:46 +0900 |
parents | c8d41c9c23c7 |
children | c6115c30a376 |
line wrap: on
line diff
--- a/mercurial/parsers.c Thu Aug 13 18:29:38 2015 +0900 +++ b/mercurial/parsers.c Thu Aug 13 18:38:46 2015 +0900 @@ -1167,6 +1167,10 @@ numheads = PyList_GET_SIZE(heads); for (i = 0; i < numheads; i++) { revnum = PyInt_AS_LONG(PyList_GET_ITEM(heads, i)); + if (revnum + 1 < 0 || revnum + 1 >= len + 1) { + PyErr_SetString(PyExc_IndexError, "head out of range"); + goto bail; + } if (seen[revnum+1] == 0) { tovisit[lentovisit++] = revnum; seen[revnum+1]=1;