-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release buffer if function returns prematurely #4381
Conversation
Regarding the lack of coverage, it is pre-existing, and I'm not convinced that these lines can be covered, practically speaking. To trigger "buffer has negative size", To cause |
Thanks! |
Resolves #4329
In
PyImaging_MapBuffer
,Py_Buffer view
is set up, and when the image is destroyed, it is released. However, if the function returns before that, thenview
is not released.The setup calls
PyObject_GetBuffer
, which is documented to requirePyBuffer_Release
- https://python.readthedocs.io/en/stable/c-api/buffer.html#c.PyObject_GetBufferSo this PR fixes a memory leak that is reported in the issue.