diff options
author | Yusuke Endoh <[email protected]> | 2024-11-25 18:23:39 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2024-11-25 20:18:48 +0900 |
commit | 92585898fb369c79e7f711465e5934ff4c1879f9 () | |
tree | 0fc6e9f2a0b771e1c9f83a7d0b7e9f90bd10e23a /ext/socket/raddrinfo.c | |
parent | 6ab76a6212853f8d43aa2505be3d198e574988ae (diff) |
Prevent memory
``` for (int i = 0; i < arg->family_size; i++) { arg->getaddrinfo_entries[i] = allocate_fast_fallback_getaddrinfo_entry(); if (!(arg->getaddrinfo_entries[i])) rb_syserr_fail(errno, "calloc(3)"); ``` If the allocation fails in the second interation, the memory allocated in the first iteration would be . This change prevents the memory by allocating the memory in advance. (The struct name `fast_fallback_getaddrinfo_shared` might no longer be good.)
Notes: Merged: https://.com/ruby/ruby/pull/12163
-rw-r--r-- | ext/socket/raddrinfo.c | 1 |
1 files changed, 0 insertions, 1 deletions
@@ -3047,7 +3047,6 @@ free_fast_fallback_getaddrinfo_entry(struct fast_fallback_getaddrinfo_entry **en freeaddrinfo((*entry)->ai); (*entry)->ai = NULL; } - free(*entry); *entry = NULL; } |