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
Check that all functions that steal a value decref it on error #135
Comments
See #63 (comment) |
This is probably most important for json_pack(). When you have multiple 'o' specifiers, and an error occurs, it's impossible for the caller to know which references where stolen and which not. The function should probably always steal the references (e.g. explicitly call decref on the remainder of 'o' specifiers not already stolen). |
Good point! Would you like to write a patch? |
@fabled I posted a patch for json_pack. Sorry if this is a duplicate message, I'm not sure if github notifies issue participants of related pull requests. |
Users of the "o" format have an expectation that the object reference will be stolen. Any error causes the collection process to end early. This patch causes json_pack and related functions to continue scanning the format and parameters so all references can be stolen to prevent leaks. This makes no attempt to continue processing if the format string is broken or missing. 'make check' still passes. Ran test_pack under valgrind and verified that the leaked reference is fixed. Added a test which uses refcounts to verify that the reference was correctly stolen after a NULL value error. Issue akheron#135
This function needs to release a reference to value if the other arguments are invalid. Issue akheron#135
The `O` format causes reference counts to increase, but in an error they are not released. Callers to unpack functions that use the `O` format should use pointers pre-initialized to NULL so they can safely release the reference on error. Also corrected typo which said this was like `O` (itself). Fixes akheron#135
No description provided.
The text was updated successfully, but these errors were encountered: