diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-23 13:57:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 13:57:50 (GMT) |
commit | 81f7359f67a7166d57a10a3d5366406d9c85f1de (patch) | |
tree | f72a35747fa77ab9c63ba70ef9e1620daddf0cc3 /Modules/posixmodule.c | |
parent | 5d9183c7ad68eb9ddb53d54a3f9a27e29dbabf31 (diff) | |
download | cpython-81f7359f67a7166d57a10a3d5366406d9c85f1de.zip cpython-81f7359f67a7166d57a10a3d5366406d9c85f1de.tar.gz cpython-81f7359f67a7166d57a10a3d5366406d9c85f1de.tar.bz2 |
gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)
Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 45e71ee..8185517 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4036,14 +4036,12 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list) Py_SETREF(v, PyUnicode_EncodeFSDefault(v)); } if (v == NULL) { - Py_DECREF(list); - list = NULL; + Py_SETREF(list, NULL); break; } if (PyList_Append(list, v) != 0) { Py_DECREF(v); - Py_DECREF(list); - list = NULL; + Py_SETREF(list, NULL); break; } Py_DECREF(v); @@ -13131,15 +13129,13 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks) PyObject *attribute = PyUnicode_DecodeFSDefaultAndSize(start, trace - start); if (!attribute) { - Py_DECREF(result); - result = NULL; + Py_SETREF(result, NULL); goto exit; } error = PyList_Append(result, attribute); Py_DECREF(attribute); if (error) { - Py_DECREF(result); - result = NULL; + Py_SETREF(result, NULL); goto exit; } start = trace + 1; |