mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
In debug mode, unicode_write_cstr() now checks that non-ASCII characters are
not written into an ASCII string
This commit is contained in:
parent
220e869a51
commit
8c6db45d3e
1 changed files with 8 additions and 0 deletions
|
@ -1700,6 +1700,14 @@ unicode_write_cstr(PyObject *unicode, Py_ssize_t index,
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case PyUnicode_1BYTE_KIND: {
|
case PyUnicode_1BYTE_KIND: {
|
||||||
assert(index + len <= PyUnicode_GET_LENGTH(unicode));
|
assert(index + len <= PyUnicode_GET_LENGTH(unicode));
|
||||||
|
#ifdef Py_DEBUG
|
||||||
|
if (PyUnicode_IS_ASCII(unicode)) {
|
||||||
|
Py_UCS4 maxchar = ucs1lib_find_max_char(
|
||||||
|
(const Py_UCS1*)str,
|
||||||
|
(const Py_UCS1*)str + len);
|
||||||
|
assert(maxchar < 128);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
memcpy((char *) data + index, str, len);
|
memcpy((char *) data + index, str, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue