diff Modules/socketmodule.c @ 20912:06d95b6877c4 legacy-trunk

Fix memory leaks detecting in bug report #478003.
author Martin v. Löwis <martin@v.loewis.de>
date Wed, 07 Nov 2001 08:31:03 +0000
parents f576ffd57966
children 90871fa43f4e
line wrap: on
line diff
--- a/Modules/socketmodule.c	Wed Nov 07 06:28:47 2001 +0000
+++ b/Modules/socketmodule.c	Wed Nov 07 08:31:03 2001 +0000
@@ -606,6 +606,7 @@
 			return -1;
 		}
 		if (res->ai_next) {
+			freeaddrinfo(res);
 			PyErr_SetString(PySocket_Error,
 				"wildcard resolved to multiple address");
 			return -1;
@@ -2461,7 +2462,8 @@
 static PyObject *
 PySocket_getaddrinfo(PyObject *self, PyObject *args)
 {
-	struct addrinfo hints, *res0, *res;
+	struct addrinfo hints, *res;
+	struct addrinfo *res0 = NULL;
 	PyObject *pobj = (PyObject *)NULL;
 	char pbuf[30];
 	char *hptr, *pptr;
@@ -2522,6 +2524,8 @@
  err:
 	Py_XDECREF(single);
 	Py_XDECREF(all);
+	if (res0)
+		freeaddrinfo(res0);
 	return (PyObject *)NULL;
 }