Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Modules/pyexpat.c
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Nov 14, 2023
1 parent 0ff6368 commit 774bb1c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Modules/pyexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 774bb1c

Please sign in to comment.