summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-06 19:47:38 (GMT)
committerGitHub <noreply@github.com>2023-09-06 19:47:38 (GMT)
commit3a08db8d137a552aebf678bcd2e7444ab72e62c5 (patch)
treed256c8449e9c8576c965f1c8f0cf4f2ac109f4d1 /Objects
parentbf414b7fcb7c8ba780a5e1d9f320ecef0c7f9488 (diff)
downloadcpython-3a08db8d137a552aebf678bcd2e7444ab72e62c5.zip
cpython-3a08db8d137a552aebf678bcd2e7444ab72e62c5.tar.gz
cpython-3a08db8d137a552aebf678bcd2e7444ab72e62c5.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 6713926..b57190d 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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);