changeset: 93479:a664b150b6c2 parent: 93477:fb3061ba6fd2 parent: 93478:ec1948191461 user: Benjamin Peterson date: Wed Nov 12 10:23:35 2014 -0500 files: Lib/test/test_io.py Misc/NEWS Modules/_io/textio.c description: merge 3.4 (#22849) diff -r fb3061ba6fd2 -r a664b150b6c2 Lib/test/test_io.py --- a/Lib/test/test_io.py Wed Nov 12 23:33:50 2014 +1000 +++ b/Lib/test/test_io.py Wed Nov 12 10:23:35 2014 -0500 @@ -2856,6 +2856,22 @@ self.assertEqual(t.read(200), bytes_val.decode('utf-8')) + def test_issue22849(self): + class F(object): + def readable(self): return True + def writable(self): return True + def seekable(self): return True + + for i in range(10): + try: + self.TextIOWrapper(F(), encoding='utf-8') + except Exception: + pass + + F.tell = lambda x: 0 + t = self.TextIOWrapper(F(), encoding='utf-8') + + class MemviewBytesIO(io.BytesIO): '''A BytesIO object whose read method returns memoryviews rather than bytes''' diff -r fb3061ba6fd2 -r a664b150b6c2 Misc/NEWS --- a/Misc/NEWS Wed Nov 12 23:33:50 2014 +1000 +++ b/Misc/NEWS Wed Nov 12 10:23:35 2014 -0500 @@ -188,6 +188,8 @@ - Issue #22578: Added attributes to the re.error class. +- Issue #22849: Fix possible double free in the io.TextIOWrapper constructor. + - Issue #12728: Different Unicode characters having the same uppercase but different lowercase are now matched in case-insensitive regular expressions. diff -r fb3061ba6fd2 -r a664b150b6c2 Modules/_io/textio.c --- a/Modules/_io/textio.c Wed Nov 12 23:33:50 2014 +1000 +++ b/Modules/_io/textio.c Wed Nov 12 10:23:35 2014 -0500 @@ -1061,7 +1061,7 @@ } /* Finished sorting out the codec details */ - Py_DECREF(codec_info); + Py_CLEAR(codec_info); self->buffer = buffer; Py_INCREF(buffer);