changeset 40088:129bfc7ad2cc

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
author Augie Fackler <augie@google.com>
date Mon, 08 Oct 2018 11:42:06 -0400
parents 1d09ba0d2ed3
children 3418f83c8874
files mercurial/cext/revlog.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }