Ensure to free fast_fallback_getaddrinfo_shared with single family (#12199)

With https://github.com/ruby/ruby/pull/12156,
the memory of the `struct fast_fallback_getaddrinfo_shared`
is now allocated even if there is only one address family.
This change will always free it when `TCPSocket.new` finishes.
This commit is contained in:
Misaki Shioi 2024-11-28 22:39:35 +09:00 committed by GitHub
parent 3af1a04741
commit 47f8a552f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-11-28 13:39:55 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>

View File

@ -1192,6 +1192,9 @@ fast_fallback_inetsock_cleanup(VALUE v)
}
if (getaddrinfo_shared) {
if (arg->family_size == 1) {
free_fast_fallback_getaddrinfo_shared(&getaddrinfo_shared);
} else {
int shared_need_free = 0;
int need_free[2] = { 0, 0 };
@ -1213,6 +1216,7 @@ fast_fallback_inetsock_cleanup(VALUE v)
}
if (shared_need_free) free_fast_fallback_getaddrinfo_shared(&getaddrinfo_shared);
}
}
int connection_attempt_fd;