[issue7561] PyByteArray_AS_STRING used unsafely

Antoine Pitrou report at bugs.python.org
Sun Jan 17 13:00:03 CET 2010


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

Here is a patch. A static empty string is used in case PyByteArray_AS_STRING() is asked on an empty bytearray, instead of returning NULL.

Another possibility would be to implement tp_new for bytearray and always allocate a new 1-byte string, but this would make the patch slightly more complicated.

(the patch also removes "nullstring", which was unused since Florent's recent patches)

----------
Added file: http://bugs.python.org/file15924/bytearray.patch

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


More information about the Python-bugs-list mailing list