Return from ImagingFill early if image has a zero dimension

This commit is contained in:
Andrew Murray 2022-12-30 16:48:33 +11:00
parent 77f6f54ac4
commit 91b01f4cc2
2 changed files with 10 additions and 0 deletions

View File

@ -512,6 +512,11 @@ class TestImage:
i = Image.new("RGB", [1, 1])
assert isinstance(i.size, tuple)
@pytest.mark.parametrize("size", ((0, 100000000), (100000000, 0)))
@pytest.mark.timeout(0.5)
def test_empty_image(self, size):
Image.new("RGB", size)
def test_storage_neg(self):
# Storage.c accepted negative values for xsize, ysize. Was
# test_neg_ppm, but the core function for that has been

View File

@ -24,6 +24,11 @@ ImagingFill(Imaging im, const void *colour) {
int x, y;
ImagingSectionCookie cookie;
/* 0-width or 0-height image. No need to do anything */
if (!im->linesize || !im->ysize) {
return im;
}
if (im->type == IMAGING_TYPE_SPECIAL) {
/* use generic API */
ImagingAccess access = ImagingAccessNew(im);