##// END OF EJS Templates
index: move check for too large capacity into nt_init()...
Martin von Zweigbergk -
r39105:4dd92a15 default
parent child Browse files
Show More
@@ -1069,6 +1069,10 b' static int nt_init(nodetree *self, index'
1069 1069 self->capacity = capacity;
1070 1070 self->depth = 0;
1071 1071 self->splits = 0;
1072 if ((size_t)self->capacity > INT_MAX / sizeof(nodetreenode)) {
1073 PyErr_SetString(PyExc_ValueError, "overflow in init_nt");
1074 return -1;
1075 }
1072 1076 self->nodes = calloc(self->capacity, sizeof(nodetreenode));
1073 1077 if (self->nodes == NULL) {
1074 1078 PyErr_NoMemory();
@@ -1133,10 +1137,6 b' static int nt_shortest(nodetree *self, c'
1133 1137 static int index_init_nt(indexObject *self)
1134 1138 {
1135 1139 if (self->nt == NULL) {
1136 if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) {
1137 PyErr_SetString(PyExc_ValueError, "overflow in index_init_nt");
1138 return -1;
1139 }
1140 1140 self->nt = PyMem_Malloc(sizeof(nodetree));
1141 1141 if (self->nt == NULL) {
1142 1142 PyErr_NoMemory();
General Comments 0
You need to be logged in to leave comments. Login now