mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-99537: Use Py_SETREF() function in C code (#99656)
Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
This commit is contained in:
parent
135ec7cefb
commit
7e3f09cad9
20 changed files with 37 additions and 89 deletions
|
@ -1074,8 +1074,7 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
|
|||
// that the dstoff is set correctly in that case.
|
||||
if (PyObject_IsTrue(tti->dstoff)) {
|
||||
_ttinfo *tti_after = &(self->tzrule_after.std);
|
||||
Py_DECREF(tti_after->dstoff);
|
||||
tti_after->dstoff = Py_NewRef(tti->dstoff);
|
||||
Py_SETREF(tti_after->dstoff, Py_NewRef(tti->dstoff));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue