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

login
register
mail settings
Submitter Augie Fackler
Date March 10, 2017, 10 p.m.
Message ID <9fa4bea85bceac8c4851.1489183221@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19085/
State Accepted
Headers show

Comments

Augie Fackler - March 10, 2017, 10 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.
Yuya Nishihara - March 10, 2017, 10:31 p.m.
On Fri, 10 Mar 2017 17:00:21 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@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.

Queued, many thanks.

Patch

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);