diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:28:22 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:28:22 (GMT) |
commit | 1a1ff29659f068659dea07f1bd67b8fd4331071c (patch) | |
tree | 20705986aa369225a02980a11f0a6a66a9eed0ee /PC/winreg.c | |
parent | e1efc07a30f4c17723c707ad761bfad538982b0c (diff) | |
download | cpython-1a1ff29659f068659dea07f1bd67b8fd4331071c.zip cpython-1a1ff29659f068659dea07f1bd67b8fd4331071c.tar.gz cpython-1a1ff29659f068659dea07f1bd67b8fd4331071c.tar.bz2 |
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
Diffstat (limited to 'PC/winreg.c')
-rw-r--r-- | PC/winreg.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/PC/winreg.c b/PC/winreg.c index 63c437e..19d5a70 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -939,7 +939,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 **)PyMem_Malloc(sizeof(wchar_t *)*s); + wchar_t **str = PyMem_New(wchar_t *, s); if (str == NULL) return PyErr_NoMemory(); @@ -1206,7 +1206,7 @@ PyEnumValue(PyObject *self, PyObject *args) ++retDataSize; bufDataSize = retDataSize; bufValueSize = retValueSize; - retValueBuf = (wchar_t *)PyMem_Malloc(sizeof(wchar_t) * retValueSize); + retValueBuf = PyMem_New(wchar_t, retValueSize); if (retValueBuf == NULL) return PyErr_NoMemory(); retDataBuf = (BYTE *)PyMem_Malloc(retDataSize); @@ -1277,7 +1277,7 @@ PyExpandEnvironmentStrings(PyObject *self, PyObject *args) return PyErr_SetFromWindowsErrWithFunction(retValueSize, "ExpandEnvironmentStrings"); } - retValue = (wchar_t *)PyMem_Malloc(retValueSize * sizeof(wchar_t)); + retValue = PyMem_New(wchar_t, retValueSize); if (retValue == NULL) { return PyErr_NoMemory(); } |