--- a/mercurial/parsers.c Sat Apr 04 11:27:15 2015 +0200
+++ b/mercurial/parsers.c Mon Apr 06 08:23:27 2015 -0700
@@ -1319,6 +1319,11 @@
static int nt_new(indexObject *self)
{
if (self->ntlength == self->ntcapacity) {
+ if (self->ntcapacity >= INT_MAX / (sizeof(nodetree) * 2)) {
+ PyErr_SetString(PyExc_MemoryError,
+ "overflow in nt_new");
+ return -1;
+ }
self->ntcapacity *= 2;
self->nt = realloc(self->nt,
self->ntcapacity * sizeof(nodetree));
@@ -1380,7 +1385,7 @@
static int nt_init(indexObject *self)
{
if (self->nt == NULL) {
- if (self->raw_length > INT_MAX) {
+ if (self->raw_length > INT_MAX / sizeof(nodetree)) {
PyErr_SetString(PyExc_ValueError, "overflow in nt_init");
return -1;
}