mirror of
https://github.com/python/cpython.git
synced 2025-10-15 11:22:18 +00:00
gh-100795: avoid unexpected freeaddrinfo
after failed getaddrinfo
(#101220)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
This commit is contained in:
parent
95f5b05a8c
commit
5f08fe4a2c
2 changed files with 4 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Avoid unexpected ``freeaddrinfo`` when :meth:`socket.socket.getaddrinfo`
|
||||||
|
fails. Patch by Sergey G. Brester.
|
|
@ -6719,6 +6719,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
|
||||||
error = getaddrinfo(hptr, pptr, &hints, &res0);
|
error = getaddrinfo(hptr, pptr, &hints, &res0);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
if (error) {
|
if (error) {
|
||||||
|
res0 = NULL; /* avoid unexpected free if res0 becomes not NULL */
|
||||||
set_gaierror(error);
|
set_gaierror(error);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -6815,6 +6816,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
|
||||||
error = getaddrinfo(hostp, pbuf, &hints, &res);
|
error = getaddrinfo(hostp, pbuf, &hints, &res);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
if (error) {
|
if (error) {
|
||||||
|
res = NULL; /* avoid unexpected free if res becomes not NULL */
|
||||||
set_gaierror(error);
|
set_gaierror(error);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue