# HG changeset patch # User Augie Fackler # Date 2015-08-18 20:40:10 # Node ID b970418bbafee1d527ec0f04d78540b4d98a50e3 # Parent af090796cb337d66d72a6b2ceb31b7ceb74e1197 parsers: set exception when there's too little string data to extract parents Previously we were returning NULL from this function without actually setting up an exception. This fixes that problem, which was detected with cpychecker. diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -481,8 +481,11 @@ static PyObject *parse_dirstate(PyObject len = readlen; /* read parents */ - if (len < 40) + if (len < 40) { + PyErr_SetString( + PyExc_ValueError, "too little data for parents"); goto quit; + } parents = Py_BuildValue("s#s#", str, 20, str + 20, 20); if (!parents)