changeset 19727:3d07b4a2f743

parsers: correctly handle a failed allocation
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 16 Sep 2013 12:17:55 -0700
parents b3c8c6f2b5c1
children 3daabd2da78b
files mercurial/parsers.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parsers.c	Mon Sep 16 12:12:37 2013 -0700
+++ b/mercurial/parsers.c	Mon Sep 16 12:17:55 2013 -0700
@@ -1212,14 +1212,19 @@
 	long sp;
 	bitmask *seen;
 
+	if (gca == NULL)
+		return PyErr_NoMemory();
+
 	for (i = 0; i < revcount; i++) {
 		if (revs[i] > maxrev)
 			maxrev = revs[i];
 	}
 
 	seen = calloc(sizeof(*seen), maxrev + 1);
-	if (seen == NULL)
+	if (seen == NULL) {
+		Py_DECREF(gca);
 		return PyErr_NoMemory();
+	}
 
 	for (i = 0; i < revcount; i++)
 		seen[revs[i]] = 1ull << i;