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:33:32 +02:00
commit 4d0d982985
15 changed files with 50 additions and 52 deletions

View file

@ -4213,9 +4213,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))