summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 0a9e465..2d300f1 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -6650,7 +6650,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
struct addrinfo *res0 = NULL;
PyObject *hobj = NULL;
PyObject *pobj = (PyObject *)NULL;
- char pbuf[30];
+ PyObject *pstr = NULL;
const char *hptr, *pptr;
int family, socktype, protocol, flags;
int error;
@@ -6680,11 +6680,13 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
return NULL;
}
if (PyLong_CheckExact(pobj)) {
- long value = PyLong_AsLong(pobj);
- if (value == -1 && PyErr_Occurred())
+ pstr = PyObject_Str(pobj);
+ if (pstr == NULL)
+ goto err;
+ assert(PyUnicode_Check(pstr));
+ pptr = PyUnicode_AsUTF8(pstr);
+ if (pptr == NULL)
goto err;
- PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value);
- pptr = pbuf;
} else if (PyUnicode_Check(pobj)) {
pptr = PyUnicode_AsUTF8(pobj);
if (pptr == NULL)
@@ -6750,12 +6752,14 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
Py_DECREF(single);
}
Py_XDECREF(idna);
+ Py_XDECREF(pstr);
if (res0)
freeaddrinfo(res0);
return all;
err:
Py_XDECREF(all);
Py_XDECREF(idna);
+ Py_XDECREF(pstr);
if (res0)
freeaddrinfo(res0);
return (PyObject *)NULL;