[issue35090] bz2: Potential division by zero in BZ2_Malloc()

2018-10-28 Thread STINNER Victor
STINNER Victor added the comment: > May be we should add a new function (_PyMem_RawMallocItems?) that does the > same checks as PyMem_RawCalloc, but doesn't zero-initialize memory? Please don't add new functions to the Python memory allocators. We already have too many of them :-(

[issue35090] bz2: Potential division by zero in BZ2_Malloc()

2018-10-28 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: May be we should add a new function (_PyMem_RawMallocItems?) that does the same checks as PyMem_RawCalloc, but doesn't zero-initialize memory? -- ___ Python tracker

[issue35090] bz2: Potential division by zero in BZ2_Malloc()

2018-10-28 Thread STINNER Victor
STINNER Victor added the comment: Check other wrappers to memory allocators: * zlib: "zst.zalloc = PyZlib_Malloc" which calls PyMem_RawMalloc * _lzma: "self->alloc.alloc = PyLzma_Malloc" which calls PyMem_RawMalloc * _bz2: "bzalloc = BZ2_Malloc" which calls PyMem_RawMalloc()

[issue35090] bz2: Potential division by zero in BZ2_Malloc()

2018-10-28 Thread Alexey Izbyshev
Change by Alexey Izbyshev : -- keywords: +patch pull_requests: +9497 stage: -> patch review ___ Python tracker ___ ___

[issue35090] bz2: Potential division by zero in BZ2_Malloc()

2018-10-28 Thread Alexey Izbyshev
New submission from Alexey Izbyshev : BZ2_Malloc() checks for size < 0 at https://github.com/python/cpython/blob/6015cc50bc38b9e920ce4986ee10658eaa14f561/Modules/_bz2module.c#L278 , but doesn't check for size == 0 before dividing by it: if (items < 0 || size < 0) return NULL;