Skip to content

Prevent reusing ImagingDecoderObject.setimage#9656

Open
Serotav wants to merge 2 commits into
python-pillow:mainfrom
Serotav:prevent-decoder-setimage-reuse
Open

Prevent reusing ImagingDecoderObject.setimage#9656
Serotav wants to merge 2 commits into
python-pillow:mainfrom
Serotav:prevent-decoder-setimage-reuse

Conversation

@Serotav
Copy link
Copy Markdown

@Serotav Serotav commented Jun 4, 2026

ImagingDecoder.setimage() binds a native decoder to an image before decoding. Reusing the same decoder with another image can leave decoder state from the previous binding in place.

This adds a defensive guard so native ImagingDecoder objects reject a second setimage() call, and adds a regression test for that behavior. Existing image loading behavior is unchanged.

Tested with:

env PYTHONPATH=src python3 -m pytest Tests/test_imagefile.py

* Move test

* Simplify code

---------

Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
@radarhere radarhere changed the title Prevent reusing ImagingDecoder.setimage Prevent reusing ImagingDecoderObject.setimage Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants