gh-111789: Use PyDict_GetItemRef() in Modules/pyexpat.c (gh-112079)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:51:31 +02:00 committed by GitHub
parent ef9b2fc9b0
commit d8908932fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,19 +240,12 @@ string_intern(xmlparseobject *self, const char* str)
return result;
if (!self->intern)
return result;
value = PyDict_GetItemWithError(self->intern, result);
if (!value) {
if (!PyErr_Occurred() &&
PyDict_SetItem(self->intern, result, result) == 0)
{
return result;
}
else {
Py_DECREF(result);
return NULL;
}
if (PyDict_GetItemRef(self->intern, result, &value) == 0 &&
PyDict_SetItem(self->intern, result, result) == 0)
{
return result;
}
Py_INCREF(value);
assert((value != NULL) == !PyErr_Occurred());
Py_DECREF(result);
return value;
}