diff mercurial/parsers.c @ 21730:8da100383dc3 stable

parsers.c: fix a couple of memory leaks
author Danek Duvall <danek.duvall@oracle.com>
date Wed, 11 Jun 2014 15:31:04 -0700
parents 628c16489d1c
children 05bd2667df4d
line wrap: on
line diff
--- 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;
 }
 
 /*