Ensure that memory is not freed before calling free_fast_fallback_getaddrinfo_* (#12661)

Ensure that `getaddrinfo_entry` and `getaddrinfo_shared` exist before free them in the main thread.
This commit is contained in:
Misaki Shioi 2025-01-29 22:19:04 +09:00 committed by GitHub
parent 2d3d7a74e9
commit 63b6323e04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-01-29 13:19:21 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>

View File

@ -1168,9 +1168,13 @@ fast_fallback_inetsock_cleanup(VALUE v)
rb_nativethread_lock_unlock(&getaddrinfo_shared->lock);
for (int i = 0; i < arg->family_size; i++) {
if (need_free[i]) free_fast_fallback_getaddrinfo_entry(&arg->getaddrinfo_entries[i]);
if (arg->getaddrinfo_entries[i] && need_free[i]) {
free_fast_fallback_getaddrinfo_entry(&arg->getaddrinfo_entries[i]);
}
}
if (getaddrinfo_shared && shared_need_free) {
free_fast_fallback_getaddrinfo_shared(&getaddrinfo_shared);
}
if (shared_need_free) free_fast_fallback_getaddrinfo_shared(&getaddrinfo_shared);
}
int connection_attempt_fd;