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.
Changes proposed in this pull request:
Image._decompression_bomb_check
directly infill
rather than duplicating its code. If an error is raised, it is propagated via theif (image == NULL)
branch.image
object by releasing the only reference to it (causing Python to call itstp_dealloc
slot, i.e._dealloc
in_imaging.c
) instead of just freeing the memory it points to (added in Improved checks in font_render #7218).typing.cast
orassert size is not None
).This partially reverts changes from #7246, which was connected to an oss-fuzz error, but I do not see any added tests or reproduction steps. IIUC, the original error was a memory leak, which I avoid in a different way in this PR:
The original code (before #7246) returned
image
viaO
format (returning a new reference) and did notPy_DECREF
(causing a memory leak).#7246 instead returns a reference via a nonlocal Python variable and added
Py_DECREF
.In this PR I have removed the nonlocal variable and return the existing reference via
N
format.See https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue for the difference between
O
andN
.