Skip to content

Commit b64d96d

Browse files
authored
Merge pull request #4116 from radarhere/memory
Fixed freeing unallocated pointer when resizing with height too large
2 parents 54e5776 + 511aed9 commit b64d96d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Tests/test_image_resample.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ class TestImagingResampleVulnerability(PillowTestCase):
1111
# see https://github.com/python-pillow/Pillow/issues/1710
1212
def test_overflow(self):
1313
im = hopper("L")
14-
xsize = 0x100000008 // 4
15-
ysize = 1000 # unimportant
16-
with self.assertRaises(MemoryError):
17-
# any resampling filter will do here
18-
im.im.resize((xsize, ysize), Image.BILINEAR)
14+
size_too_large = 0x100000008 // 4
15+
size_normal = 1000 # unimportant
16+
for xsize, ysize in (
17+
(size_too_large, size_normal),
18+
(size_normal, size_too_large),
19+
):
20+
with self.assertRaises(MemoryError):
21+
# any resampling filter will do here
22+
im.im.resize((xsize, ysize), Image.BILINEAR)
1923

2024
def test_invalid_size(self):
2125
im = hopper()

src/libImaging/Resample.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,6 @@ ImagingResampleInner(Imaging imIn, int xsize, int ysize,
627627
if ( ! ksize_vert) {
628628
free(bounds_horiz);
629629
free(kk_horiz);
630-
free(bounds_vert);
631-
free(kk_vert);
632630
return NULL;
633631
}
634632

0 commit comments

Comments
 (0)