Skip to content

Commit 91bf01d

Browse files
authored
pythongh-87804: Fix the refleak in error handling of _pystatvfs_fromstructstatfs (python#115335)
It was the macro expansion! Sorry!
1 parent 9182201 commit 91bf01d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Modules/posixmodule.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -12916,14 +12916,15 @@ _pystatvfs_fromstructstatfs(PyObject *module, struct statfs st) {
1291612916

1291712917
_Static_assert(sizeof(st.f_blocks) == sizeof(long long), "assuming large file");
1291812918

12919-
#define SET_ITEM(v, index, item) \
12920-
do { \
12921-
if (item == NULL) { \
12922-
Py_DECREF(v); \
12923-
return NULL; \
12924-
} \
12925-
PyStructSequence_SET_ITEM(v, index, item); \
12926-
} while (0) \
12919+
#define SET_ITEM(SEQ, INDEX, EXPR) \
12920+
do { \
12921+
PyObject *obj = (EXPR); \
12922+
if (obj == NULL) { \
12923+
Py_DECREF((SEQ)); \
12924+
return NULL; \
12925+
} \
12926+
PyStructSequence_SET_ITEM((SEQ), (INDEX), obj); \
12927+
} while (0)
1292712928

1292812929
SET_ITEM(v, 0, PyLong_FromLong((long) st.f_iosize));
1292912930
SET_ITEM(v, 1, PyLong_FromLong((long) st.f_bsize));

0 commit comments

Comments
 (0)