mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +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))
|
Image.new("RGB", (10, 10))
|
||||||
|
|
||||||
self.assertRaises(ValueError, Image.core.set_blocks_max, -1)
|
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")
|
@unittest.skipIf(is_pypy, "images are not collected")
|
||||||
def test_set_blocks_max_stats(self):
|
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");
|
"blocks_max should be greater than 0");
|
||||||
return NULL;
|
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)) {
|
if ( ! ImagingMemorySetBlocksMax(&ImagingDefaultArena, blocks_max)) {
|
||||||
ImagingError_MemoryError();
|
ImagingError_MemoryError();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user