mirror of
https://github.com/python/cpython.git
synced 2025-09-01 14:38:00 +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:
parent
e1efc07a30
commit
1a1ff29659
15 changed files with 50 additions and 52 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue