parsers.c: fix a couple of memory leaks stable
authorDanek Duvall <danek.duvall@oracle.com>
Wed, 11 Jun 2014 15:31:04 -0700
branchstable
changeset 21730 8da100383dc3
parent 21709 14560418856d
child 21748 8621125a1718
parsers.c: fix a couple of memory leaks
mercurial/parsers.c
--- a/mercurial/parsers.c	Mon May 26 19:02:11 2014 +0200
+++ b/mercurial/parsers.c	Wed Jun 11 15:31:04 2014 -0700
@@ -1299,7 +1299,7 @@
 	static const Py_ssize_t capacity = 24;
 	int *depth, *interesting = NULL;
 	int i, j, v, ninteresting;
-	PyObject *dict = NULL, *keys;
+	PyObject *dict = NULL, *keys = NULL;
 	long *seen = NULL;
 	int maxrev = -1;
 	long final;
@@ -1403,8 +1403,10 @@
 		final |= i;
 		j -= 1;
 	}
-	if (final == 0)
-		return PyList_New(0);
+	if (final == 0) {
+		keys = PyList_New(0);
+		goto bail;
+	}
 
 	dict = PyDict_New();
 	if (dict == NULL)
@@ -1428,19 +1430,13 @@
 
 	keys = PyDict_Keys(dict);
 
-	free(depth);
-	free(seen);
-	free(interesting);
-	Py_DECREF(dict);
-
-	return keys;
 bail:
 	free(depth);
 	free(seen);
 	free(interesting);
 	Py_XDECREF(dict);
 
-	return NULL;
+	return keys;
 }
 
 /*