]> granicus.if.org Git - python/commitdiff
_PyUnicodeWriter_WriteStr() now checks that the input string is consistent
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 26 Mar 2015 08:37:23 +0000 (09:37 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 26 Mar 2015 08:37:23 +0000 (09:37 +0100)
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.

Objects/unicodeobject.c

index 5343b2106fb2710ff4dd054ce0858dfae39c1e01..e494e4a14643923bea0f8362ea9cd5b5647fedef 100644 (file)
@@ -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;