summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-26 09:37:23 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-03-26 09:37:23 +0100
commit1912b39deffe416f6b0c16df64b634a3e55fd424 (patch)
tree823fe8024c934e74f13a51bb20564f291914245d
parentaa4c36fbbb47fe54d578cb7f04f53179360e5aa7 (diff)
downloadcpython-git-1912b39deffe416f6b0c16df64b634a3e55fd424.tar.gz
_PyUnicodeWriter_WriteStr() now checks that the input string is consistent
in debug mode to detect bugs earlier. _PyUnicodeWriter_Finish() doesn't check if the read only string is consistent, whereas it does check consistency for strings built by itself.
-rw-r--r--Objects/unicodeobject.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5343b2106f..e494e4a146 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13422,6 +13422,7 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
maxchar = PyUnicode_MAX_CHAR_VALUE(str);
if (maxchar > writer->maxchar || len > writer->size - writer->pos) {
if (writer->buffer == NULL && !writer->overallocate) {
+ assert(_PyUnicode_CheckConsistency(str, 1));
writer->readonly = 1;
Py_INCREF(str);
writer->buffer = str;