summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2024-12-11 14:44:50 -0800
committerJohn Hawthorn <[email protected]>2024-12-11 15:37:32 -0800
commitd84859061a39b81b85bdbae8cfff5088a5c78a93 ()
treee80a4ac0dfe6da78c832f2df994264eebfd88ff8
parent9fe6fd86936ead769fe983feb5461ca4f192f16e (diff)
Use ruby_strdup/xfree in fast_fallback
Any memory allocated with xmalloc needs to be matched with xfree rather than plain free. Ruby unfortunately redefines strdup to be ruby_strdup, which uses xmalloc so needs to be xfreed. Previously these were mismatched. This commit changes the copy to be an explicit ruby_strdup (to avoid confusion) and the free to be xfree.
Notes: Merged: https://.com/ruby/ruby/pull/12311
-rw-r--r--ext/socket/ipsocket.c4
-rw-r--r--ext/socket/raddrinfo.c4
2 files changed, 4 insertions, 4 deletions
@@ -592,8 +592,8 @@ init_fast_fallback_inetsock_internal(VALUE v)
rb_nativethread_lock_initialize(&arg->getaddrinfo_shared->lock);
arg->getaddrinfo_shared->notify = hostname_resolution_notifier;
- arg->getaddrinfo_shared->node = arg->hostp ? strdup(arg->hostp) : NULL;
- arg->getaddrinfo_shared->service = strdup(arg->portp);
arg->getaddrinfo_shared->refcount = arg->family_size + 1;
for (int i = 0; i < arg->family_size; i++) {
@@ -3029,9 +3029,9 @@ rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
void
free_fast_fallback_getaddrinfo_shared(struct fast_fallback_getaddrinfo_shared **shared)
{
- free((*shared)->node);
(*shared)->node = NULL;
- free((*shared)->service);
(*shared)->service = NULL;
rb_nativethread_lock_destroy(&(*shared)->lock);
free(*shared);