Commit f0b11d28 authored by Martin v. Löwis's avatar Martin v. Löwis

Fix memory leaks detecting in bug report #478003.

parent 0b663104
...@@ -571,12 +571,14 @@ get_addr(hostname, af, res, pai, port0) ...@@ -571,12 +571,14 @@ get_addr(hostname, af, res, pai, port0)
error = EAI_FAIL; error = EAI_FAIL;
break; break;
} }
goto bad; goto free;
} }
if ((hp->h_name == NULL) || (hp->h_name[0] == 0) || if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
(hp->h_addr_list[0] == NULL)) (hp->h_addr_list[0] == NULL)) {
ERR(EAI_FAIL); error = EAI_FAIL;
goto free;
}
for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) { for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
switch (af) { switch (af) {
...@@ -632,7 +634,7 @@ get_addr(hostname, af, res, pai, port0) ...@@ -632,7 +634,7 @@ get_addr(hostname, af, res, pai, port0)
if (hp) if (hp)
freehostent(hp); freehostent(hp);
#endif #endif
bad: /* bad: */
*res = NULL; *res = NULL;
return error; return error;
} }
...@@ -606,6 +606,7 @@ setipaddr(char* name, struct sockaddr * addr_ret, int af) ...@@ -606,6 +606,7 @@ setipaddr(char* name, struct sockaddr * addr_ret, int af)
return -1; return -1;
} }
if (res->ai_next) { if (res->ai_next) {
freeaddrinfo(res);
PyErr_SetString(PySocket_Error, PyErr_SetString(PySocket_Error,
"wildcard resolved to multiple address"); "wildcard resolved to multiple address");
return -1; return -1;
...@@ -2461,7 +2462,8 @@ PySocket_inet_ntoa(PyObject *self, PyObject *args) ...@@ -2461,7 +2462,8 @@ PySocket_inet_ntoa(PyObject *self, PyObject *args)
static PyObject * static PyObject *
PySocket_getaddrinfo(PyObject *self, PyObject *args) PySocket_getaddrinfo(PyObject *self, PyObject *args)
{ {
struct addrinfo hints, *res0, *res; struct addrinfo hints, *res;
struct addrinfo *res0 = NULL;
PyObject *pobj = (PyObject *)NULL; PyObject *pobj = (PyObject *)NULL;
char pbuf[30]; char pbuf[30];
char *hptr, *pptr; char *hptr, *pptr;
...@@ -2522,6 +2524,8 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args) ...@@ -2522,6 +2524,8 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args)
err: err:
Py_XDECREF(single); Py_XDECREF(single);
Py_XDECREF(all); Py_XDECREF(all);
if (res0)
freeaddrinfo(res0);
return (PyObject *)NULL; return (PyObject *)NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment