Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer

overflows.  Added few missed PyErr_NoMemory().
This commit is contained in:
Serhiy Storchaka 2015-02-16 13:28:22 +02:00
parent e1efc07a30
commit 1a1ff29659
15 changed files with 50 additions and 52 deletions

View file

@ -4126,9 +4126,11 @@ socket_gethostname(PyObject *self, PyObject *unused)
/* MSDN says ERROR_MORE_DATA may occur because DNS allows longer
names */
name = PyMem_Malloc(size * sizeof(wchar_t));
if (!name)
name = PyMem_New(wchar_t, size);
if (!name) {
PyErr_NoMemory();
return NULL;
}
if (!GetComputerNameExW(ComputerNamePhysicalDnsHostname,
name,
&size))