diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-22 13:22:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 13:22:22 (GMT) |
commit | 7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e (patch) | |
tree | a8d4dda9e9128545442794595f5ebc96a5c1c7b4 /Modules/_zoneinfo.c | |
parent | 135ec7cefbaffd516b77362ad2b2ad1025af462e (diff) | |
download | cpython-7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e.zip cpython-7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e.tar.gz cpython-7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e.tar.bz2 |
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.
Diffstat (limited to 'Modules/_zoneinfo.c')
-rw-r--r-- | Modules/_zoneinfo.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 34f5abd..c0fef13 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -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)); } } |