equal
deleted
inserted
replaced
1067 { |
1067 { |
1068 self->index = index; |
1068 self->index = index; |
1069 self->capacity = capacity; |
1069 self->capacity = capacity; |
1070 self->depth = 0; |
1070 self->depth = 0; |
1071 self->splits = 0; |
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 self->nodes = calloc(self->capacity, sizeof(nodetreenode)); |
1076 self->nodes = calloc(self->capacity, sizeof(nodetreenode)); |
1073 if (self->nodes == NULL) { |
1077 if (self->nodes == NULL) { |
1074 PyErr_NoMemory(); |
1078 PyErr_NoMemory(); |
1075 return -1; |
1079 return -1; |
1076 } |
1080 } |
1131 } |
1135 } |
1132 |
1136 |
1133 static int index_init_nt(indexObject *self) |
1137 static int index_init_nt(indexObject *self) |
1134 { |
1138 { |
1135 if (self->nt == NULL) { |
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 self->nt = PyMem_Malloc(sizeof(nodetree)); |
1140 self->nt = PyMem_Malloc(sizeof(nodetree)); |
1141 if (self->nt == NULL) { |
1141 if (self->nt == NULL) { |
1142 PyErr_NoMemory(); |
1142 PyErr_NoMemory(); |
1143 return -1; |
1143 return -1; |
1144 } |
1144 } |