# HG changeset patch # User Augie Fackler # Date 2018-10-08 15:42:06 # Node ID 129bfc7ad2ccac6775041ec7751d67b01f57c8cd # Parent 1d09ba0d2ed3d19f1ca1b116591cc413eb87ac65 revlog: if the module is initialized more than once, don't leak nullentry Caught (annoyingly) by the manifest fuzzer. Differential Revision: https://phab.mercurial-scm.org/D4905 diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -2304,8 +2304,10 @@ void revlog_module_init(PyObject *mod) Py_INCREF(&nodetreeType); PyModule_AddObject(mod, "nodetree", (PyObject *)&nodetreeType); - nullentry = Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, - -1, -1, -1, -1, nullid, 20); + if (!nullentry) { + nullentry = Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, + -1, -1, -1, -1, nullid, 20); + } if (nullentry) PyObject_GC_UnTrack(nullentry); }