parsers: handle refcounting of "parents" consistently
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 13 Mar 2017 17:49:13 -0700
changeset 31426 43a7dfbead0c
parent 31425 63a39d647888
child 31427 b2fb0fd239b8
parsers: handle refcounting of "parents" consistently Py_None can be refcounted like any other Python object. So do that.
mercurial/parsers.c
--- a/mercurial/parsers.c	Wed Mar 15 09:32:18 2017 -0700
+++ b/mercurial/parsers.c	Mon Mar 13 17:49:13 2017 -0700
@@ -2739,6 +2739,7 @@
 		data += nparents * hashwidth;
 	} else {
 		parents = Py_None;
+		Py_INCREF(parents);
 	}
 
 	if (data + 2 * nmetadata > dataend) {
@@ -2781,8 +2782,7 @@
 	Py_XDECREF(prec);
 	Py_XDECREF(succs);
 	Py_XDECREF(metadata);
-	if (parents != Py_None)
-		Py_XDECREF(parents);
+	Py_XDECREF(parents);
 	return ret;
 }