mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-106307: Fix PyMapping_GetOptionalItemString() (GH-108797)
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.
This commit is contained in:
parent
bf414b7fcb
commit
3a08db8d13
2 changed files with 39 additions and 0 deletions
|
@ -2393,11 +2393,13 @@ int
|
|||
PyMapping_GetOptionalItemString(PyObject *obj, const char *key, PyObject **result)
|
||||
{
|
||||
if (key == NULL) {
|
||||
*result = NULL;
|
||||
null_error();
|
||||
return -1;
|
||||
}
|
||||
PyObject *okey = PyUnicode_FromString(key);
|
||||
if (okey == NULL) {
|
||||
*result = NULL;
|
||||
return -1;
|
||||
}
|
||||
int rc = PyMapping_GetOptionalItem(obj, okey, result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue