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

Skip to content

Commit 04d09eb

Browse files
Issue #23785: Fixed memory leak in TextIOWrapper.tell() in rare circumstances.
1 parent 4aa8679 commit 04d09eb

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
@@ -2435,14 +2435,10 @@ textiowrapper_tell(textio *self, PyObject *args)
24352435
if (saved_state) {
24362436
PyObject *type, *value, *traceback;
24372437
PyErr_Fetch(&type, &value, &traceback);
2438-
24392438
res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
2439+
_PyErr_ChainExceptions(type, value, traceback);
24402440
Py_DECREF(saved_state);
2441-
if (res == NULL)
2442-
return NULL;
2443-
Py_DECREF(res);
2444-
2445-
PyErr_Restore(type, value, traceback);
2441+
Py_XDECREF(res);
24462442
}
24472443
return NULL;
24482444
}

0 commit comments

Comments
 (0)