Skip to content

Commit b8bdb13

Browse files
committed
add assert size * itemisze < size_t in buffer alloc func
1 parent 0bd7ec1 commit b8bdb13

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Modules/arraymodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ enum machine_format_code {
154154
static arraydata *
155155
arraydata_alloc(Py_ssize_t size, int itemsize)
156156
{
157+
assert (size <= PY_SSIZE_T_MAX / itemsize);
157158
Py_ssize_t bufsize = sizeof(arraydata) + size * itemsize;
158159
arraydata *data = (arraydata *)PyMem_Malloc(bufsize);
159160
if (data == NULL) {

0 commit comments

Comments
 (0)