[PATCH 4 of 7] parsers.c: fix a memory leak in index_commonancestorsheads

Augie Fackler raf at durin42.com
Fri Jan 23 15:06:41 CST 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1422045706 18000
#      Fri Jan 23 15:41:46 2015 -0500
# Branch stable
# Node ID 42f1449f31b50b60109570b6203b5b330817d123
# Parent  72365a74930dfeae8b7e7bce3e2beef6d6d95c5f
parsers.c: fix a memory leak in index_commonancestorsheads

Spotted with cpychecker.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1793,9 +1793,11 @@ static PyObject *index_commonancestorshe
 		if (!PyInt_Check(obj)) {
 			PyErr_SetString(PyExc_TypeError,
 					"arguments must all be ints");
+			Py_DECREF(obj);
 			goto bail;
 		}
 		val = PyInt_AsLong(obj);
+		Py_DECREF(obj);
 		if (val == -1) {
 			ret = PyList_New(0);
 			goto done;


More information about the Mercurial-devel mailing list