D4164: index: move check for too large capacity into nt_init()
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sun Aug 12 00:46:15 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4dd92a15fcca: index: move check for too large capacity into nt_init() (authored by martinvonz, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4164?vs=10090&id=10337
REVISION DETAIL
https://phab.mercurial-scm.org/D4164
AFFECTED FILES
mercurial/cext/revlog.c
CHANGE DETAILS
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1069,6 +1069,10 @@
self->capacity = capacity;
self->depth = 0;
self->splits = 0;
+ if ((size_t)self->capacity > INT_MAX / sizeof(nodetreenode)) {
+ PyErr_SetString(PyExc_ValueError, "overflow in init_nt");
+ return -1;
+ }
self->nodes = calloc(self->capacity, sizeof(nodetreenode));
if (self->nodes == NULL) {
PyErr_NoMemory();
@@ -1133,10 +1137,6 @@
static int index_init_nt(indexObject *self)
{
if (self->nt == NULL) {
- if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) {
- PyErr_SetString(PyExc_ValueError, "overflow in index_init_nt");
- return -1;
- }
self->nt = PyMem_Malloc(sizeof(nodetree));
if (self->nt == NULL) {
PyErr_NoMemory();
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list