summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-11-02 23:34:52 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-11-02 23:34:52 (GMT)
commit06b1d21e7d33b2f77c05a7d8a1c51c1713f716ee (patch)
tree3f5b695ba6357fa2d324ac637d4340d8b9723643 /Modules
parent6b45b1ee52091a0adf2abee3b244c0b0b69da6da (diff)
downloadcpython-06b1d21e7d33b2f77c05a7d8a1c51c1713f716ee.zip
cpython-06b1d21e7d33b2f77c05a7d8a1c51c1713f716ee.tar.gz
cpython-06b1d21e7d33b2f77c05a7d8a1c51c1713f716ee.tar.bz2
Correct getnameinfo refcounting and tuple parsing. Fixes #476648.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index e5d850c..1ecb281 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2537,18 +2537,17 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
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;
+ if (!PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, &scope_id))
return NULL;
- n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
- if (n == 0)
- goto fail;
PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
@@ -2597,7 +2596,6 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
fail:
if (res)
freeaddrinfo(res);
- Py_XDECREF(sa);
return ret;
}