diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-08-07 11:55:15 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-08-07 11:55:15 (GMT) |
commit | 5db099a4feeff163ca8fc37db08c3e4339cc2886 (patch) | |
tree | f7b6b1d8f938b56499710975f9eff1f002afe09f /Modules/socketmodule.c | |
parent | 7edd0a9b21d28fceed4594332b72e794242ce0e0 (diff) | |
download | cpython-5db099a4feeff163ca8fc37db08c3e4339cc2886.zip cpython-5db099a4feeff163ca8fc37db08c3e4339cc2886.tar.gz cpython-5db099a4feeff163ca8fc37db08c3e4339cc2886.tar.bz2 |
Release host name memory. Fixes #783312. Will backport to 2.3.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d402339..36b4b3d 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -956,7 +956,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, { struct sockaddr_in* addr; char *host; - int port; + int port, result; addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { PyErr_Format( @@ -969,7 +969,10 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; - if (setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET) < 0) + result = setipaddr(host, (struct sockaddr *)addr, + sizeof(*addr), AF_INET); + PyMem_Free(host); + if (result < 0) return 0; addr->sin_family = AF_INET; addr->sin_port = htons((short)port); @@ -983,7 +986,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, { struct sockaddr_in6* addr; char *host; - int port, flowinfo, scope_id; + int port, flowinfo, scope_id, result; addr = (struct sockaddr_in6*)&(s->sock_addr).in6; flowinfo = scope_id = 0; if (!PyArg_ParseTuple(args, "eti|ii", @@ -991,7 +994,10 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, &scope_id)) { return 0; } - if (setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6) < 0) + result = setipaddr(host, (struct sockaddr *)addr, + sizeof(*addr), AF_INET6); + PyMem_Free(host); + if (result < 0) return 0; addr->sin6_family = s->sock_family; addr->sin6_port = htons((short)port); @@ -3100,7 +3106,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args) pptr = (char *)NULL; } else { PyErr_SetString(socket_error, "Int or String expected"); - return NULL; + goto err; } memset(&hints, 0, sizeof(hints)); hints.ai_family = family; @@ -3114,7 +3120,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args) RELEASE_GETADDRINFO_LOCK /* see comment in setipaddr() */ if (error) { set_gaierror(error); - return NULL; + goto err; } if ((all = PyList_New(0)) == NULL) |