diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 13:33:32 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 13:33:32 +0200 |
commit | 4d0d9829851915e97ae392dd803976be6c95c8d1 (patch) | |
tree | e93666c54592b95dbca422ec66d0896f827957b3 /PC | |
parent | Fixed few compiler warnings. (diff) | |
parent | Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer (diff) | |
download | cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.tar.gz cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.tar.bz2 cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.zip |
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
Diffstat (limited to 'PC')
-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 63c437e437e..19d5a703918 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(); } |