diff options
author | Brett Cannon <brett@python.org> | 2012-03-06 15:33:24 -0500 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-03-06 15:33:24 -0500 |
commit | f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24 (patch) | |
tree | ceed84488164142e5884411566de19f66702c3e7 /Objects/unicodeobject.c | |
parent | 0d4d410b2d6891520b1772a85f5ebdf926a0c77e (diff) | |
parent | 0119e4753eec50f671ee716af202b4a1ca28deef (diff) | |
download | cpython-git-f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24.tar.gz |
merge
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a4dcdf61c2..5c1071325d 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -998,7 +998,11 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar) is_sharing = 1; } else { - assert(maxchar <= MAX_UNICODE); + if (maxchar > MAX_UNICODE) { + PyErr_SetString(PyExc_SystemError, + "invalid maximum character passed to PyUnicode_New"); + return NULL; + } kind_state = PyUnicode_4BYTE_KIND; char_size = 4; if (sizeof(wchar_t) == 4) @@ -3942,6 +3946,10 @@ PyUnicode_WriteChar(PyObject *unicode, Py_ssize_t index, Py_UCS4 ch) } if (unicode_check_modifiable(unicode)) return -1; + if (ch > PyUnicode_MAX_CHAR_VALUE(unicode)) { + PyErr_SetString(PyExc_ValueError, "character out of range"); + return -1; + } PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode), index, ch); return 0; |