[PATCH 1 of 2] parsers: avoid leak of nonnset and otherpset

Augie Fackler raf at durin42.com
Fri Mar 10 22:00:21 UTC 2017


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1489182780 18000
#      Fri Mar 10 16:53:00 2017 -0500
# Node ID 9fa4bea85bceac8c4851520a9fd9cfe604a53649
# Parent  718a57e95a897f4ac407ae3733a7d41e87354acb
parsers: avoid leak of nonnset and otherpset

Py_BuildValue increments the refcount, rather than stealing the
reference, which I missed in code review.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -604,6 +604,8 @@ static PyObject *nonnormalotherparentent
 	result = Py_BuildValue("(OO)", nonnset, otherpset);
 	if (result == NULL)
 		goto bail;
+	Py_DECREF(nonnset);
+	Py_DECREF(otherpset);
 	return result;
 bail:
 	Py_XDECREF(nonnset);


More information about the Mercurial-devel mailing list