revlog: if the module is initialized more than once, don't leak nullentry
authorAugie Fackler <augie@google.com>
Mon, 08 Oct 2018 11:42:06 -0400
changeset 40088 129bfc7ad2cc
parent 40087 1d09ba0d2ed3
child 40089 3418f83c8874
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
mercurial/cext/revlog.c
--- 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);
 }