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
--- a/mercurial/cext/revlog.c Mon Oct 01 14:31:15 2018 -0700
+++ b/mercurial/cext/revlog.c Mon Oct 08 11:42:06 2018 -0400
@@ -2304,8 +2304,10 @@
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);
}