summaryrefslogtreecommitdiffstats
path: root/Modules/_struct.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-23 13:57:50 (GMT)
committerGitHub <noreply@github.com>2022-11-23 13:57:50 (GMT)
commit81f7359f67a7166d57a10a3d5366406d9c85f1de (patch)
treef72a35747fa77ab9c63ba70ef9e1620daddf0cc3 /Modules/_struct.c
parent5d9183c7ad68eb9ddb53d54a3f9a27e29dbabf31 (diff)
downloadcpython-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/_struct.c')
-rw-r--r--Modules/_struct.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 2f2eb25..c960b81 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -2164,8 +2164,7 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
_structmodulestate *state = get_struct_state(module);
if (fmt == NULL) {
- Py_DECREF(*ptr);
- *ptr = NULL;
+ Py_SETREF(*ptr, NULL);
return 1;
}