diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:33:32 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:33:32 (GMT) |
commit | 4d0d9829851915e97ae392dd803976be6c95c8d1 (patch) | |
tree | e93666c54592b95dbca422ec66d0896f827957b3 /PC | |
parent | 53fa8b2a4bbb589d3d761284c70f93e0f852df23 (diff) | |
parent | 1a1ff29659f068659dea07f1bd67b8fd4331071c (diff) | |
download | cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.zip cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.tar.gz cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.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')
-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(); } |