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

Skip to content

Commit 2e1c4e5

Browse files
Issue #23785: Fixed memory leak in TextIOWrapper.tell() in rare circumstances.
2 parents be1c60c + 04d09eb commit 2e1c4e5

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

Modules/_io/textio.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,14 +2441,10 @@ textiowrapper_tell(textio *self, PyObject *args)
24412441
if (saved_state) {
24422442
PyObject *type, *value, *traceback;
24432443
PyErr_Fetch(&type, &value, &traceback);
2444-
24452444
res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
2445+
_PyErr_ChainExceptions(type, value, traceback);
24462446
Py_DECREF(saved_state);
2447-
if (res == NULL)
2448-
return NULL;
2449-
Py_DECREF(res);
2450-
2451-
PyErr_Restore(type, value, traceback);
2447+
Py_XDECREF(res);
24522448
}
24532449
return NULL;
24542450
}

0 commit comments

Comments
 (0)