mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -938,7 +938,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
|
|||
wchar_t *data = (wchar_t *)retDataBuf;
|
||||
int len = retDataSize / 2;
|
||||
int s = countStrings(data, len);
|
||||
wchar_t **str = (wchar_t **)malloc(sizeof(wchar_t *)*s);
|
||||
wchar_t **str = (wchar_t **)PyMem_Malloc(sizeof(wchar_t *)*s);
|
||||
if (str == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
||||
|
@ -959,7 +959,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
|
|||
index,
|
||||
PyUnicode_FromWideChar(str[index], len));
|
||||
}
|
||||
free(str);
|
||||
PyMem_Free(str);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue