diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2024-02-12 16:27:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 16:27:27 (GMT) |
commit | 91bf01d4b15a40be4510fd9ee5e6dc8e9c019fce (patch) | |
tree | 178b015a356f1f38dc316d4fb3bfb902552cc85b /Modules/posixmodule.c | |
parent | 91822018eeba12a6c9eabbc748363b2fd4291b30 (diff) | |
download | cpython-91bf01d4b15a40be4510fd9ee5e6dc8e9c019fce.zip cpython-91bf01d4b15a40be4510fd9ee5e6dc8e9c019fce.tar.gz cpython-91bf01d4b15a40be4510fd9ee5e6dc8e9c019fce.tar.bz2 |
gh-87804: Fix the refleak in error handling of `_pystatvfs_fromstructstatfs` (#115335)
It was the macro expansion! Sorry!
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 17032d9..ef6d656 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12916,14 +12916,15 @@ _pystatvfs_fromstructstatfs(PyObject *module, struct statfs st) { _Static_assert(sizeof(st.f_blocks) == sizeof(long long), "assuming large file"); -#define SET_ITEM(v, index, item) \ - do { \ - if (item == NULL) { \ - Py_DECREF(v); \ - return NULL; \ - } \ - PyStructSequence_SET_ITEM(v, index, item); \ - } while (0) \ +#define SET_ITEM(SEQ, INDEX, EXPR) \ + do { \ + PyObject *obj = (EXPR); \ + if (obj == NULL) { \ + Py_DECREF((SEQ)); \ + return NULL; \ + } \ + PyStructSequence_SET_ITEM((SEQ), (INDEX), obj); \ + } while (0) SET_ITEM(v, 0, PyLong_FromLong((long) st.f_iosize)); SET_ITEM(v, 1, PyLong_FromLong((long) st.f_bsize)); |