mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Merge pull request #3703 from jkrshnmenon/master
Add an upper limit for blocks_max in _set_blocks_max
This commit is contained in:
commit
372c7c352a
|
@ -105,6 +105,8 @@ class TestCoreMemory(PillowTestCase):
|
|||
Image.new("RGB", (10, 10))
|
||||
|
||||
self.assertRaises(ValueError, Image.core.set_blocks_max, -1)
|
||||
if sys.maxsize < 2 ** 32:
|
||||
self.assertRaises(ValueError, Image.core.set_blocks_max, 2 ** 29)
|
||||
|
||||
@unittest.skipIf(is_pypy, "images are not collected")
|
||||
def test_set_blocks_max_stats(self):
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user