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

login
register
mail settings
Submitter Augie Fackler
Date Jan. 23, 2015, 9:06 p.m.
Message ID <42f1449f31b50b601095.1422047201@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7540/
State Accepted
Commit 33d6aaf84c9e9820c6c974ac498acbc12187466b
Headers show

Comments

Augie Fackler - Jan. 23, 2015, 9:06 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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;