Skip to content

Commit

Permalink
pythongh-87804: Fix the refleak in error handling of `_pystatvfs_from…
Browse files Browse the repository at this point in the history
…structstatfs` (python#115335)

It was the macro expansion! Sorry!
  • Loading branch information
sobolevn authored and fsc-eriker committed Feb 14, 2024
1 parent cac468f commit 2bcdda7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Modules/posixmodule.c
Expand Up @@ -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));
Expand Down

0 comments on commit 2bcdda7

Please sign in to comment.