mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #18408: Fix _PyUnicodeWriter_Finish(): clear writer->buffer,
so _PyUnicodeWriter_Dealloc() can be called on the writer after finish.
This commit is contained in:
parent
064bbdc79b
commit
15a0bd3965
1 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue