mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
This commit is contained in:
commit
4d0d982985
15 changed files with 50 additions and 52 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue