[issue44068] Possible divide by zero problems

2021-05-10 Thread STINNER Victor
STINNER Victor added the comment: > Should we add an explicit check on variable char_size before using it in > division? Search for "There are 4 forms of Unicode strings" in Include/cpython/unicodeobject.h. char_size cannot be 0 in resize_compact(): it's checked by 2 assertions: assert

[issue44068] Possible divide by zero problems

2021-05-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It cannot be 0 if PyUnicode_IS_READY() returns true. -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue44068] Possible divide by zero problems

2021-05-07 Thread yiyuaner
New submission from yiyuaner : In the file Objects/unicodeobject.c, we have the following code: static PyObject* resize_compact(PyObject *unicode, Py_ssize_t length) { ... char_size = PyUnicode_KIND(unicode); ... if (length > ((PY_SSIZE_T_MAX - struct_size) / char_size - 1)) { PyErr