Project

General

Profile

« Previous | Next » 

Revision 92585898

Added by mame (Yusuke Endoh) about 1 year ago

Prevent memory leak

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 leaked.

This change prevents the memory leak by allocating the memory in
advance.
(The struct name fast_fallback_getaddrinfo_shared might no longer be
good.)