@@ -3000,12 +3000,16 @@ socket_gethostbyname(PyObject *self, PyObject *args)
3000
3000
{
3001
3001
char * name ;
3002
3002
sock_addr_t addrbuf ;
3003
+ PyObject * ret = NULL ;
3003
3004
3004
- if (!PyArg_ParseTuple (args , "s :gethostbyname" , & name ))
3005
+ if (!PyArg_ParseTuple (args , "et :gethostbyname" , "idna " , & name ))
3005
3006
return NULL ;
3006
3007
if (setipaddr (name , SAS2SA (& addrbuf ), sizeof (addrbuf ), AF_INET ) < 0 )
3007
- return NULL ;
3008
- return makeipaddr (SAS2SA (& addrbuf ), sizeof (struct sockaddr_in ));
3008
+ goto finally ;
3009
+ ret = makeipaddr (SAS2SA (& addrbuf ), sizeof (struct sockaddr_in ));
3010
+ finally :
3011
+ PyMem_Free (name );
3012
+ return ret ;
3009
3013
}
3010
3014
3011
3015
PyDoc_STRVAR (gethostbyname_doc ,
@@ -3156,7 +3160,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
3156
3160
struct sockaddr_in addr ;
3157
3161
#endif
3158
3162
struct sockaddr * sa ;
3159
- PyObject * ret ;
3163
+ PyObject * ret = NULL ;
3160
3164
#ifdef HAVE_GETHOSTBYNAME_R
3161
3165
struct hostent hp_allocated ;
3162
3166
#ifdef HAVE_GETHOSTBYNAME_R_3_ARG
@@ -3171,10 +3175,10 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
3171
3175
#endif
3172
3176
#endif /* HAVE_GETHOSTBYNAME_R */
3173
3177
3174
- if (!PyArg_ParseTuple (args , "s :gethostbyname_ex" , & name ))
3178
+ if (!PyArg_ParseTuple (args , "et :gethostbyname_ex" , "idna " , & name ))
3175
3179
return NULL ;
3176
3180
if (setipaddr (name , (struct sockaddr * )& addr , sizeof (addr ), AF_INET ) < 0 )
3177
- return NULL ;
3181
+ goto finally ;
3178
3182
Py_BEGIN_ALLOW_THREADS
3179
3183
#ifdef HAVE_GETHOSTBYNAME_R
3180
3184
#if defined(HAVE_GETHOSTBYNAME_R_6_ARG )
@@ -3204,6 +3208,8 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
3204
3208
#ifdef USE_GETHOSTBYNAME_LOCK
3205
3209
PyThread_release_lock (netdb_lock );
3206
3210
#endif
3211
+ finally :
3212
+ PyMem_Free (name );
3207
3213
return ret ;
3208
3214
}
3209
3215
@@ -3228,7 +3234,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
3228
3234
struct sockaddr * sa = (struct sockaddr * )& addr ;
3229
3235
char * ip_num ;
3230
3236
struct hostent * h ;
3231
- PyObject * ret ;
3237
+ PyObject * ret = NULL ;
3232
3238
#ifdef HAVE_GETHOSTBYNAME_R
3233
3239
struct hostent hp_allocated ;
3234
3240
#ifdef HAVE_GETHOSTBYNAME_R_3_ARG
@@ -3250,11 +3256,11 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
3250
3256
int al ;
3251
3257
int af ;
3252
3258
3253
- if (!PyArg_ParseTuple (args , "s :gethostbyaddr" , & ip_num ))
3259
+ if (!PyArg_ParseTuple (args , "et :gethostbyaddr" , "idna " , & ip_num ))
3254
3260
return NULL ;
3255
3261
af = AF_UNSPEC ;
3256
3262
if (setipaddr (ip_num , sa , sizeof (addr ), af ) < 0 )
3257
- return NULL ;
3263
+ goto finally ;
3258
3264
af = sa -> sa_family ;
3259
3265
ap = NULL ;
3260
3266
al = 0 ;
@@ -3271,7 +3277,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
3271
3277
#endif
3272
3278
default :
3273
3279
PyErr_SetString (socket_error , "unsupported address family" );
3274
- return NULL ;
3280
+ goto finally ;
3275
3281
}
3276
3282
Py_BEGIN_ALLOW_THREADS
3277
3283
#ifdef HAVE_GETHOSTBYNAME_R
@@ -3298,6 +3304,8 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
3298
3304
#ifdef USE_GETHOSTBYNAME_LOCK
3299
3305
PyThread_release_lock (netdb_lock );
3300
3306
#endif
3307
+ finally :
3308
+ PyMem_Free (ip_num );
3301
3309
return ret ;
3302
3310
}
3303
3311
0 commit comments