[issue27570] Avoid memcpy(. . ., NULL, 0) etc calls

Martin Panter report at bugs.python.org
Wed Aug 3 01:31:36 EDT 2016


Martin Panter added the comment:

Patch 3 fixes some more cases I found in the array module:

>>> a + a
Modules/arraymodule.c:809:5: runtime error: null pointer passed as argument 1, which is declared to never be null
Modules/arraymodule.c:809:5: runtime error: null pointer passed as argument 2, which is declared to never be null
Modules/arraymodule.c:810:5: runtime error: null pointer passed as argument 1, which is declared to never be null
Modules/arraymodule.c:810:5: runtime error: null pointer passed as argument 2, which is declared to never be null
array('B')
>>> a * 3
Modules/arraymodule.c:840:9: runtime error: null pointer passed as argument 1, which is declared to never be null
Modules/arraymodule.c:840:9: runtime error: null pointer passed as argument 2, which is declared to never be null
array('B')
>>> a += a
Modules/arraymodule.c:952:5: runtime error: null pointer passed as argument 1, which is declared to never be null
Modules/arraymodule.c:952:5: runtime error: null pointer passed as argument 2, which is declared to never be null

I wondered if there is a good argument for fixing these, or if it is only a theoretical problem. Apparently GCC can do optimizations about null pointer tests: <https://gcc.gnu.org/gcc-4.9/porting_to.html>. I don’t think any of the cases I found are instances of this problem, but I think fixing them helps keep the UB sanitizer output clean, so any errors causing practical behaviour problems will be easier to find.

----------
Added file: http://bugs.python.org/file43987/memcpy-null.v3.patch

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


More information about the Python-bugs-list mailing list