Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/_bz2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ BZ2_Malloc(void* ctx, int items, int size)
{
if (items < 0 || size < 0)
return NULL;
if ((size_t)items > (size_t)PY_SSIZE_T_MAX / (size_t)size)
if (size != 0 && (size_t)items > (size_t)PY_SSIZE_T_MAX / (size_t)size)
return NULL;
/* PyMem_Malloc() cannot be used: compress() and decompress()
release the GIL */
return PyMem_RawMalloc(items * size);
return PyMem_RawMalloc((size_t)items * (size_t)size);
}

static void
Expand Down
2 changes: 1 addition & 1 deletion Modules/_lzmamodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ catch_lzma_error(lzma_ret lzret)
static void*
PyLzma_Malloc(void *opaque, size_t items, size_t size)
{
if (items > (size_t)PY_SSIZE_T_MAX / size)
if (size != 0 && items > (size_t)PY_SSIZE_T_MAX / size)
return NULL;
/* PyMem_Malloc() cannot be used:
the GIL is not held when lzma_code() is called */
Expand Down
4 changes: 2 additions & 2 deletions Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ newcompobject(PyTypeObject *type)
static void*
PyZlib_Malloc(voidpf ctx, uInt items, uInt size)
{
if (items > (size_t)PY_SSIZE_T_MAX / size)
if (size != 0 && items > (size_t)PY_SSIZE_T_MAX / size)
return NULL;
/* PyMem_Malloc() cannot be used: the GIL is not held when
inflate() and deflate() are called */
return PyMem_RawMalloc(items * size);
return PyMem_RawMalloc((size_t)items * (size_t)size);
}

static void
Expand Down