diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -572,6 +572,17 @@ &offset, &stop)) { return NULL; } + if (offset < 0) { + PyErr_SetString(PyExc_ValueError, + "invalid negative offset in fm1readmarkers"); + return NULL; + } + if (stop > datalen) { + PyErr_SetString( + PyExc_ValueError, + "stop longer than data length in fm1readmarkers"); + return NULL; + } dataend = data + datalen; data += offset; markers = PyList_New(0);