summaryrefslogtreecommitdiff
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-16 13:28:22 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-16 13:28:22 +0200
commit1a1ff29659f068659dea07f1bd67b8fd4331071c (patch)
tree20705986aa369225a02980a11f0a6a66a9eed0ee /Modules/socketmodule.c
parente1efc07a30f4c17723c707ad761bfad538982b0c (diff)
downloadcpython-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.c6
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))