diff options
| author | Victor Stinner <vstinner@python.org> | 2022-11-22 14:22:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-22 14:22:22 +0100 |
| commit | 7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e (patch) | |
| tree | a8d4dda9e9128545442794595f5ebc96a5c1c7b4 /Modules/_functoolsmodule.c | |
| parent | 135ec7cefbaffd516b77362ad2b2ad1025af462e (diff) | |
| download | cpython-git-7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e.tar.gz | |
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/_functoolsmodule.c')
| -rw-r--r-- | Modules/_functoolsmodule.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 9b30f41ec6..4032ba7937 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1243,8 +1243,7 @@ lru_cache_clear_list(lru_list_elem *link) { while (link != NULL) { lru_list_elem *next = link->next; - Py_DECREF(link); - link = next; + Py_SETREF(link, next); } } |
