parsers: correctly handle a failed allocation
authorBryan O'Sullivan <bryano@fb.com>
Mon, 16 Sep 2013 12:17:55 -0700
changeset 19727 3d07b4a2f743
parent 19726 b3c8c6f2b5c1
child 19728 3daabd2da78b
parsers: correctly handle a failed allocation
mercurial/parsers.c
--- 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;