diff Modules/socketmodule.c @ 20853:77bb2ae067c2 legacy-trunk

Correct getnameinfo refcounting and tuple parsing. Fixes #476648.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 02 Nov 2001 23:34:52 +0000
parents 828bf317880a
children f576ffd57966
line wrap: on
line diff
--- a/Modules/socketmodule.c	Fri Nov 02 22:55:15 2001 +0000
+++ b/Modules/socketmodule.c	Fri Nov 02 23:34:52 2001 +0000
@@ -2537,18 +2537,17 @@
 	PyObject *sa = (PyObject *)NULL;
 	int flags;
 	char *hostp;
-	int n, port, flowinfo, scope_id;
+	int port, flowinfo, scope_id;
 	char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
 	struct addrinfo hints, *res = NULL;
 	int error;
 	PyObject *ret = (PyObject *)NULL;
 
 	flags = flowinfo = scope_id = 0;
-	if (PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags) == 0)
+	if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags))
 		return NULL;
-	n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
-	if (n == 0)
-		goto fail;
+	if  (!PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, &scope_id))
+		return NULL;
 	PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
 	memset(&hints, 0, sizeof(hints));
 	hints.ai_family = PF_UNSPEC;
@@ -2597,7 +2596,6 @@
 fail:
 	if (res)
 		freeaddrinfo(res);
-	Py_XDECREF(sa);
 	return ret;
 }