gh-100795: avoid unexpected freeaddrinfo after failed getaddrinfo (#101220)

Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
This commit is contained in:
Sergey G. Brester 2023-01-22 09:10:00 +01:00 committed by GitHub
parent 95f5b05a8c
commit 5f08fe4a2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -6719,6 +6719,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
error = getaddrinfo(hptr, pptr, &hints, &res0);
Py_END_ALLOW_THREADS
if (error) {
res0 = NULL; /* avoid unexpected free if res0 becomes not NULL */
set_gaierror(error);
goto err;
}
@ -6815,6 +6816,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
error = getaddrinfo(hostp, pbuf, &hints, &res);
Py_END_ALLOW_THREADS
if (error) {
res = NULL; /* avoid unexpected free if res becomes not NULL */
set_gaierror(error);
goto fail;
}