From patchwork Mon Sep 16 19:27:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3,in,crew] parsers: correctly handle a failed allocation From: Bryan O'Sullivan X-Patchwork-Id: 2503 Message-Id: <3d07b4a2f7438cc54e87.1379359652@australite.local> To: mercurial-devel@selenic.com Date: Mon, 16 Sep 2013 12:27:32 -0700 # HG changeset patch # User Bryan O'Sullivan # Date 1379359075 25200 # Mon Sep 16 12:17:55 2013 -0700 # Node ID 3d07b4a2f7438cc54e8771d4db14dd1cd4b69fee # Parent b3c8c6f2b5c146c9d3464058ff40d031a97b371d parsers: correctly handle a failed allocation diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -1212,14 +1212,19 @@ static PyObject *find_gca_candidates(ind 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;