Skip to content

Improve freeing objects on errors in PyImaging_GrabScreenWin32() - #10094

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:screen_grab
Oct 3, 2026
Merged

radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:screen_grab

Conversation

@radarhere

Copy link
Copy Markdown
Member

Resolves #10092 with the suggested fix.

@akx akx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor nit :)

Comment thread src/display.c
Comment on lines -411 to +415
return NULL;
goto error;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the idea with the repeated PyErr_SetStrings is that this branch will retain the error from PyBytes_FromStringAndSize 👍

Comment thread src/display.c Outdated
Co-authored-by: Aarni Koskela <akx@iki.fi>
@radarhere
radarhere merged commit 40237e0 into python-pillow:main Oct 3, 2026
59 of 60 checks passed
@radarhere
radarhere deleted the screen_grab branch October 3, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImageGrab.grab() on Windows leaks a GDI bitmap on every failed grab

2 participants