diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 13:28:22 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 13:28:22 +0200 |
commit | 1a1ff29659f068659dea07f1bd67b8fd4331071c (patch) | |
tree | 20705986aa369225a02980a11f0a6a66a9eed0ee /Modules/socketmodule.c | |
parent | e1efc07a30f4c17723c707ad761bfad538982b0c (diff) | |
download | cpython-git-1a1ff29659f068659dea07f1bd67b8fd4331071c.tar.gz |
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index cb44d05b62..e9feba378e 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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)) |