diff options
author | Andy Lester <andy@petdance.com> | 2020-03-24 23:26:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-24 23:26:44 -0500 |
commit | 7668a8bc93c2bd573716d1bea0f52ea520502b28 (patch) | |
tree | 0c6dce63a06466c3f9136df09f5cd928d20e5c55 /PC | |
parent | bpo-1635741: Port _functools module to multiphase initialization (PEP 489) (G... (diff) | |
download | cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.tar.gz cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.tar.bz2 cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.zip |
Use calloc-based functions, not malloc. (GH-19152)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/_testconsole.c | 3 | ||||
-rw-r--r-- | PC/getpathp.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/PC/_testconsole.c b/PC/_testconsole.c index 23d1286ed4f..f6fcfcf1964 100644 --- a/PC/_testconsole.c +++ b/PC/_testconsole.c @@ -55,10 +55,9 @@ _testconsole_write_input_impl(PyObject *module, PyObject *file, const wchar_t *p = (const wchar_t *)PyBytes_AS_STRING(s); DWORD size = (DWORD)PyBytes_GET_SIZE(s) / sizeof(wchar_t); - rec = (INPUT_RECORD*)PyMem_Malloc(sizeof(INPUT_RECORD) * size); + rec = (INPUT_RECORD*)PyMem_Calloc(size, sizeof(INPUT_RECORD)); if (!rec) goto error; - memset(rec, 0, sizeof(INPUT_RECORD) * size); INPUT_RECORD *prec = rec; for (DWORD i = 0; i < size; ++i, ++p, ++prec) { diff --git a/PC/getpathp.c b/PC/getpathp.c index 3b65b35ce61..7a2c1fd6fe6 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -370,11 +370,10 @@ getpythonregpath(HKEY keyBase, int skipcore) /* Allocate a temp array of char buffers, so we only need to loop reading the registry once */ - ppPaths = PyMem_RawMalloc( sizeof(WCHAR *) * numKeys ); + ppPaths = PyMem_RawCalloc(numKeys, sizeof(WCHAR *)); if (ppPaths==NULL) { goto done; } - memset(ppPaths, 0, sizeof(WCHAR *) * numKeys); /* Loop over all subkeys, allocating a temp sub-buffer. */ for(index=0;index<numKeys;index++) { WCHAR keyBuf[MAX_PATH+1]; |