-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
v3.2.x: Fix leaks in C++ code #17468
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
Conversation
PyObject *meta_key, *meta_val; | ||
Py_ssize_t pos = 0; | ||
int meta_pos = 0; | ||
std::vector<PyObject*> temp_strs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know if it is worth it, but when doing push_back()s to a vector, one can save a fair amount of memory and allocation time by doing temp_strs.reserve(meta_size);
before the loop for strings since we know the upper limit for this vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect it won't be more than 10 or maybe 20, but I've added it since we do know the limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to make sense to me.
If `info_ptr` isn't created, we should still destroy `png_ptr`.
PR Summary
This is a cherry-pick of the leak fix in #17458, and another leak fix in the png code (which doesn't exist on
master
.)PR Checklist