-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-106307: Fix PyMapping_GetOptionalItemString() #108797
gh-106307: Fix PyMapping_GetOptionalItemString() #108797
Conversation
The resulting pointer was not set to NULL if the creation of a temporary string object was failed. The tests were also missed due to oversight.
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.
LGTM. I just propose adding a comment on the new macro.
Does Valgrind or similar tool detect the usage of uninitialized memory?
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.
LGTM.
The _testcapi now intializes the variable used in the test:
static PyObject *
mapping_getoptionalitemstring(PyObject *self, PyObject *args)
{
PyObject *obj, *value = UNINITIALIZED_PTR;
@erlend-aasland: Idea for the devguide: We should suggest to always initialized the |
I have a PR for this, and you already approved it twice 😃 python/devguide#1128 |
There are exceptions, like |
Exceptions are fine; guidelines are for the general case, not the special case. |
Alright, I should approve it 3 or 4 times 👍👍👍👍 |
The resulting pointer was not set to NULL if the creation of a temporary string object was failed.
The tests were also missed due to oversight.