Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return from ImagingFill early if image has a zero dimension #6842

Merged
merged 2 commits into from Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/test_image.py
Expand Up @@ -512,6 +512,11 @@ def test_check_size(self):
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
Expand Down
5 changes: 5 additions & 0 deletions src/libImaging/Fill.c
Expand Up @@ -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);
Expand Down