]> granicus.if.org Git - python/commitdiff
PyUnicode_New() and unicode_putchar() check for MAX_UNICODE maximum (U+10FFFF)
authorVictor Stinner <vstinner@wyplay.com>
Wed, 22 Feb 2012 12:36:20 +0000 (13:36 +0100)
committerVictor Stinner <vstinner@wyplay.com>
Wed, 22 Feb 2012 12:36:20 +0000 (13:36 +0100)
Objects/unicodeobject.c

index a42aad9ade23f1ba61658e79cced7cea229dd261..afe7a9fa68d2c4298987407ca450c9f865f52a4d 100644 (file)
@@ -998,6 +998,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
             is_sharing = 1;
     }
     else {
+        assert(maxchar <= MAX_UNICODE);
         kind_state = PyUnicode_4BYTE_KIND;
         char_size = 4;
         if (sizeof(wchar_t) == 4)
@@ -1627,6 +1628,7 @@ static int
 unicode_putchar(PyObject **p_unicode, Py_ssize_t *pos,
                 Py_UCS4 ch)
 {
+    assert(ch <= MAX_UNICODE);
     if (unicode_widen(p_unicode, ch) < 0)
         return -1;
     PyUnicode_WRITE(PyUnicode_KIND(*p_unicode),