mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #18203: Replace malloc() with PyMem_Malloc() in Python modules
Replace malloc() with PyMem_Malloc() when the GIL is held, or with PyMem_RawMalloc() otherwise.
This commit is contained in:
parent
1a7425f67a
commit
b64049183c
10 changed files with 52 additions and 55 deletions
|
@ -165,7 +165,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
|
|||
|
||||
zst.avail_out = length + length/1000 + 12 + 1;
|
||||
|
||||
output = (Byte*)malloc(zst.avail_out);
|
||||
output = (Byte*)PyMem_Malloc(zst.avail_out);
|
||||
if (output == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError,
|
||||
"Can't allocate memory to compress data");
|
||||
|
@ -218,7 +218,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
|
|||
|
||||
error:
|
||||
PyBuffer_Release(&pinput);
|
||||
free(output);
|
||||
PyMem_Free(output);
|
||||
|
||||
return ReturnVal;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue