Kaydet (Commit) 720acbf3 authored tarafından Berker Peksag's avatar Berker Peksag

Issue #27981: Fix refleak in fp_setreadl()

Patch by David Dudson.
üst 7927e757
...@@ -497,7 +497,7 @@ error: ...@@ -497,7 +497,7 @@ error:
static int static int
fp_setreadl(struct tok_state *tok, const char* enc) fp_setreadl(struct tok_state *tok, const char* enc)
{ {
PyObject *readline = NULL, *stream = NULL, *io = NULL; PyObject *readline = NULL, *stream = NULL, *io = NULL, *bufobj;
_Py_IDENTIFIER(open); _Py_IDENTIFIER(open);
_Py_IDENTIFIER(readline); _Py_IDENTIFIER(readline);
int fd; int fd;
...@@ -528,9 +528,12 @@ fp_setreadl(struct tok_state *tok, const char* enc) ...@@ -528,9 +528,12 @@ fp_setreadl(struct tok_state *tok, const char* enc)
readline = _PyObject_GetAttrId(stream, &PyId_readline); readline = _PyObject_GetAttrId(stream, &PyId_readline);
Py_XSETREF(tok->decoding_readline, readline); Py_XSETREF(tok->decoding_readline, readline);
if (pos > 0) { if (pos > 0) {
if (PyObject_CallObject(readline, NULL) == NULL) { bufobj = PyObject_CallObject(readline, NULL);
if (bufobj == NULL) {
readline = NULL; readline = NULL;
goto cleanup; goto cleanup;
} else {
Py_DECREF(bufobj);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment