Skip to content

Commit b1c9d56

Browse files
committed
Fix refleak in error path
1 parent 78f8087 commit b1c9d56

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Modules/_winapi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,12 +3114,11 @@ _winapi_GetProcessMemoryInfo_impl(PyObject *module, HANDLE handle)
31143114
do { \
31153115
PyObject *obj = PyLong_FromSize_t(pmc.ATTR); \
31163116
if (obj == NULL) { \
3117-
Py_DECREF(result); \
3118-
return NULL; \
3117+
goto error; \
31193118
} \
31203119
if (PyDict_SetItemString(result, #ATTR, obj) < 0) { \
31213120
Py_DECREF(obj); \
3122-
return NULL; \
3121+
goto error; \
31233122
} \
31243123
Py_DECREF(obj); \
31253124
} while (0)
@@ -3135,6 +3134,10 @@ _winapi_GetProcessMemoryInfo_impl(PyObject *module, HANDLE handle)
31353134
ADD(PeakPagefileUsage);
31363135

31373136
return result;
3137+
3138+
error:
3139+
Py_DECREF(result);
3140+
return NULL;
31383141
}
31393142

31403143

0 commit comments

Comments
 (0)