From 15e9ed299c5cd8adca21ac5e8e9691eacc731700 Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@wyplay.com>
Date: Wed, 22 Feb 2012 13:36:20 +0100
Subject: [PATCH] PyUnicode_New() and unicode_putchar() check for MAX_UNICODE
 maximum (U+10FFFF)

---
 Objects/unicodeobject.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index a42aad9ade..afe7a9fa68 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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),
-- 
2.40.0