summaryrefslogtreecommitdiffstats
path: root/PC/winreg.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-16 11:28:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-16 11:28:22 (GMT)
commit1a1ff29659f068659dea07f1bd67b8fd4331071c (patch)
tree20705986aa369225a02980a11f0a6a66a9eed0ee /PC/winreg.c
parente1efc07a30f4c17723c707ad761bfad538982b0c (diff)
downloadcpython-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.c6
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();
}