adding an upper limit for blocks_max in _set_blocks_max

This commit is contained in:
Jayakrishna Menon 2019-03-08 11:30:35 -07:00 committed by Andrew Murray
parent ea570a8c5b
commit 37516fb665

View File

@ -3625,6 +3625,12 @@ _set_blocks_max(PyObject* self, PyObject* args)
"blocks_max should be greater than 0");
return NULL;
}
else if ( blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) {
PyErr_SetString(PyExc_ValueError,
"blocks_max is too large");
return NULL;
}
if ( ! ImagingMemorySetBlocksMax(&ImagingDefaultArena, blocks_max)) {
ImagingError_MemoryError();