]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_PyUnicodeWriter: assert that max character <= MAX_UNICODE
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 6 Sep 2016 23:58:36 +0000 (16:58 -0700)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 6 Sep 2016 23:58:36 +0000 (16:58 -0700)
Objects/unicodeobject.c

index b96333ce472622816a7cb4764e118673444af2bc..9ecf0e16d3c96ca7870b5aa6096fd59138824482 100644 (file)
@@ -13348,6 +13348,8 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
     Py_ssize_t newlen;
     PyObject *newbuffer;
 
+    assert(maxchar <= MAX_UNICODE);
+
     /* ensure that the _PyUnicodeWriter_Prepare macro was used */
     assert((maxchar > writer->maxchar && length >= 0)
            || length > 0);
@@ -13441,6 +13443,7 @@ _PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
 Py_LOCAL_INLINE(int)
 _PyUnicodeWriter_WriteCharInline(_PyUnicodeWriter *writer, Py_UCS4 ch)
 {
+    assert(ch <= MAX_UNICODE);
     if (_PyUnicodeWriter_Prepare(writer, 1, ch) < 0)
         return -1;
     PyUnicode_WRITE(writer->kind, writer->data, writer->pos, ch);