mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +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
|
|
@ -709,9 +709,7 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss
|
|||
if (memokey == NULL) {
|
||||
goto bail;
|
||||
}
|
||||
Py_INCREF(memokey);
|
||||
Py_DECREF(key);
|
||||
key = memokey;
|
||||
Py_SETREF(key, Py_NewRef(memokey));
|
||||
idx = next_idx;
|
||||
|
||||
/* skip whitespace between key and : delimiter, read :, skip whitespace */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue