[issue8092] utf8, backslashreplace and surrogates

Antoine Pitrou report at bugs.python.org
Tue Apr 20 23:09:54 CEST 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

> I don't know if "nallocated += repsize - 4;" can overflow or not.
> If yes, how can I detect the overflow?

Sure, if they are both Py_ssize_t, just use:

if (nallocated > PY_SSIZE_T_MAX - repsize + 4) {
  /* handle overflow ... */
}

----------
nosy: +pitrou

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8092>
_______________________________________


More information about the Python-bugs-list mailing list