diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-08 20:29:55 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-08 20:29:55 (GMT) |
commit | 15a0bd39658461165fd3b56ba92be5f53f8cc5a0 (patch) | |
tree | bd06a69926fbc3a4814a76a09bf758525642d1bd /Objects/unicodeobject.c | |
parent | 064bbdc79bc34cdc26988e0344c289e42a19e79c (diff) | |
download | cpython-15a0bd39658461165fd3b56ba92be5f53f8cc5a0.zip cpython-15a0bd39658461165fd3b56ba92be5f53f8cc5a0.tar.gz cpython-15a0bd39658461165fd3b56ba92be5f53f8cc5a0.tar.bz2 |
Issue #18408: Fix _PyUnicodeWriter_Finish(): clear writer->buffer,
so _PyUnicodeWriter_Dealloc() can be called on the writer after finish.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ac5f66a..96c7c58 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13157,6 +13157,7 @@ _PyUnicodeWriter_WriteCstr(_PyUnicodeWriter *writer, const char *str, Py_ssize_t PyObject * _PyUnicodeWriter_Finish(_PyUnicodeWriter *writer) { + PyObject *str; if (writer->pos == 0) { Py_XDECREF(writer->buffer); _Py_RETURN_UNICODE_EMPTY(); @@ -13174,8 +13175,10 @@ _PyUnicodeWriter_Finish(_PyUnicodeWriter *writer) } writer->buffer = newbuffer; } - assert(_PyUnicode_CheckConsistency(writer->buffer, 1)); - return unicode_result_ready(writer->buffer); + str = writer->buffer; + writer->buffer = NULL; + assert(_PyUnicode_CheckConsistency(str, 1)); + return unicode_result_ready(str); } void |