DmitryJ added the comment:

>From the author's page at http://effbot.org/zone/stringlib.htm

"Note that the above Python code may access s[n], which would result in an 
IndexError exception. For the CPython implementation, this is not really a 
problem, since CPython adds trailing NULL entries to both 8-bit and Unicode 
strings."

Apparently, this flaw was known to the author, but was not documented in C code.

A possible quick-and-dirty solution is to treat m=n as a special case and 
resort to memcmp() or somesuch as there is no actual need to perform multiple 
match tries. This should fix things for bytearray and str in case str's 
implementation changes from appending a trailing NUL.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24462>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to