Improve reference handling in encode.c - #9920
Conversation
akx
left a comment
There was a problem hiding this comment.
There's a couple more error exits in the function that should maybe be covered?
(Should this function use the goto cleanup;/goto failed; pattern?)
There was a problem hiding this comment.
Should this also decref the encoder?
There was a problem hiding this comment.
Should this also decref the encoder?
There was a problem hiding this comment.
Should this also decref the encoder?
|
|
||
| pack = ImagingFindPacker(mode, rawmode, &bits); | ||
| if (!pack) { | ||
| Py_DECREF(encoder); |
There was a problem hiding this comment.
Hmm, hold on... get_packer already does Py_DECREF(encoder) if ImagingFindPacker fails.
akx
left a comment
There was a problem hiding this comment.
Given get_packer decrefs the encoder itself on error return, I think these are wrong to add. Should probably check if there are other pre-existing places that assume this should be done?
Follows up on python-pillow#8216 (GetItemRefs are new references, GetItem used to be a borrowed one)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
Suggestions for python-pillow#9920
No description provided.