From patchwork Tue Aug 7 12:52:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D4153: index: remove side-effect from failed nt_init() From: phabricator X-Patchwork-Id: 33392 Message-Id: <8637a5c0c7fd3accdfb655b5a6fbdc6a@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Tue, 7 Aug 2018 12:52:20 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHGf7d8fb2ed8a8: index: remove side-effect from failed nt_init() (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4153?vs=10034&id=10048 REVISION DETAIL https://phab.mercurial-scm.org/D4153 AFFECTED FILES mercurial/cext/revlog.c CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -1092,15 +1092,15 @@ static int nt_init(indexObject *self) { if (self->nt == NULL) { + if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) { + PyErr_SetString(PyExc_ValueError, "overflow in nt_init"); + return -1; + } self->nt = PyMem_Malloc(sizeof(nodetree)); if (self->nt == NULL) { PyErr_NoMemory(); return -1; } - if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) { - PyErr_SetString(PyExc_ValueError, "overflow in nt_init"); - return -1; - } self->nt->capacity = self->raw_length < 4 ? 4 : (int)self->raw_length / 2;