Address more feedback; don't unlock around sizeof

This commit is contained in:
Lysandros Nikolaou 2024-07-16 21:31:29 +02:00
parent 06767fc325
commit 98b173928a
No known key found for this signature in database
GPG Key ID: 43E92D11D08F5F29

View File

@ -4093,10 +4093,8 @@ _set_blocks_max(PyObject *self, PyObject *args) {
return NULL;
}
MUTEX_LOCK(&ImagingDefaultArena.mutex);
size_t blocksize = sizeof(ImagingDefaultArena.blocks_pool[0]);
MUTEX_UNLOCK(&ImagingDefaultArena.mutex);
if ((unsigned long)blocks_max > SIZE_MAX / blocksize) {
if ((unsigned long)blocks_max > SIZE_MAX /
sizeof(ImagingDefaultArena.blocks_pool[0])) {
PyErr_SetString(PyExc_ValueError, "blocks_max is too large");
return NULL;
}