Repository navigation
Conversation
gdk_pixbuf_format_get_name transfers ownership of its returned string. Copying it with ffi.string without releasing the original allocation leaks memory on every image decode, accumulating hundreds of megabytes in long-running clients that repeatedly render SVG images. Declare g_free in the Pixbuf FFI and release the name in a finally block after conversion. Cover both successful conversion and decoding errors with regression tests that check the allocated pointer is freed once. Co-Authored-By: Codex CLI <noreply@openai.com>
3 tasks
Member
|
Hi, Thanks to follow the contribution guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated image decoding leaks the C string returned by
gdk_pixbuf_format_get_name(): the return value is caller-owned, butdecode_to_pixbuf()copies it into Python and drops the original pointer. A long-running Qtile process accumulated approximately 404 MiB of 32-byte allocations containingsvg; an isolated 100,000-call reproduction of the format-name conversion increased glibc allocated memory by 3,199,936 bytes.Declare
g_freein the Pixbuf FFI and free the returned name in afinallyblock after copying it. The returned Python format name is unchanged. Regression tests check that the exact allocated pointer is freed once both on successful decoding and when ASCII decoding raises.Validation: the two new regression cases fail before the fix and pass afterward;
uv run --extra test -m pytestreports 55 passed, 1 skipped (optional XCB dependency unavailable), anduv run --extra test -m ruff checkpasses.