Skip to content

Segfault if you blur an image with zero width xor zero height #8346

@marnanel

Description

@marnanel

What did you do?

This code segfaults immediately:

from PIL import Image, ImageFilter i = Image.new( size = (0, 1), mode = 'RGBA', ) i = i.filter(ImageFilter.BoxBlur(1))

If the param to BoxBlur is 0, it correctly does nothing. If the height and width of the Image are zero, it correctly does nothing. If one of the dimensions is zero and the other is positive, it segfaults.

What did you expect to happen?

Nothing at all.

What actually happened?

A segfault.

What are your OS, Python and Pillow versions?

  • OS: Debian 12.7
  • Python: 3.11.2
  • Pillow: 10.4.0
-------------------------------------------------------------------- Pillow 10.4.0 Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] -------------------------------------------------------------------- Python executable is /home/marnanel/proj/douglas/venv/bin/python Environment Python files loaded from /home/marnanel/proj/douglas/venv System Python files loaded from /usr -------------------------------------------------------------------- Python Pillow modules loaded from /home/marnanel/proj/douglas/venv/lib/python3.11/site-packages/PIL Binary Pillow modules loaded from /home/marnanel/proj/douglas/venv/lib/python3.11/site-packages/PIL -------------------------------------------------------------------- --- PIL CORE support ok, compiled for 10.4.0 --- TKINTER support ok, loaded 8.6 --- FREETYPE2 support ok, loaded 2.13.2 --- LITTLECMS2 support ok, loaded 2.16 --- WEBP support ok, loaded 1.4.0 --- WEBP Transparency support ok --- WEBPMUX support ok --- WEBP Animation support ok --- JPEG support ok, compiled for libjpeg-turbo 3.0.3 --- OPENJPEG (JPEG2000) support ok, loaded 2.5.2 --- ZLIB (PNG/ZIP) support ok, loaded 1.2.13 --- LIBTIFF support ok, loaded 4.6.0 --- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.8, harfbuzz 8.5.0 *** LIBIMAGEQUANT (Quantization method) support not installed --- XCB (X protocol) support ok -------------------------------------------------------------------- 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions