Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdd3567

Browse files
authored
_tkinter: Fix refleak in getint() (#2153)
PyNumber_Int() creates a new reference: need to decrement result reference counter.
1 parent 15a6127 commit bdd3567

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Modules/_tkinter.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -2131,8 +2131,12 @@ Tkapp_GetInt(PyObject *self, PyObject *args)
21312131
result = fromWideIntObj(self, value);
21322132
#endif
21332133
Tcl_DecrRefCount(value);
2134-
if (result != NULL)
2135-
return PyNumber_Int(result);
2134+
if (result != NULL) {
2135+
PyObject *resint = PyNumber_Int(result);
2136+
Py_DECREF(result);
2137+
return resint;
2138+
}
2139+
21362140
if (PyErr_Occurred())
21372141
return NULL;
21382142
#else

0 commit comments

Comments
 (0)