diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-13 04:39:00 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-09-13 04:39:00 (GMT) |
commit | 720acbf31b960bd6fb5f6bf2ad6a3e319428749c (patch) | |
tree | 55b8c81619456796db5d087e9537ecce2f495560 | |
parent | 7927e75758e8ac7285876490d7192c9953eb4ac4 (diff) | |
download | cpython-720acbf31b960bd6fb5f6bf2ad6a3e319428749c.zip cpython-720acbf31b960bd6fb5f6bf2ad6a3e319428749c.tar.gz cpython-720acbf31b960bd6fb5f6bf2ad6a3e319428749c.tar.bz2 |
Issue #27981: Fix refleak in fp_setreadl()
Patch by David Dudson.
-rw-r--r-- | Parser/tokenizer.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 184ffe7..784b98c 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -497,7 +497,7 @@ error: static int 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(readline); int fd; @@ -528,9 +528,12 @@ fp_setreadl(struct tok_state *tok, const char* enc) readline = _PyObject_GetAttrId(stream, &PyId_readline); Py_XSETREF(tok->decoding_readline, readline); if (pos > 0) { - if (PyObject_CallObject(readline, NULL) == NULL) { + bufobj = PyObject_CallObject(readline, NULL); + if (bufobj == NULL) { readline = NULL; goto cleanup; + } else { + Py_DECREF(bufobj); } } |