Skip to content

Commit 9e07edf

Browse files
committed
Fix freeaddrinfo(), which did not match allocation in JS. fixes #16081
1 parent a703ee7 commit 9e07edf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

system/lib/libc/musl/src/network/freeaddrinfo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66

77
void freeaddrinfo(struct addrinfo *p)
88
{
9+
#if __EMSCRIPTEN__
10+
// Emscripten's usage of this structure is very simple: we always allocate
11+
// ai_addr, and do not use the linked list aspect at all. There is also no
12+
// aliasing with aibuf.
13+
free(p->ai_addr);
14+
free(p);
15+
#else
916
size_t cnt;
1017
for (cnt=1; p->ai_next; cnt++, p=p->ai_next);
1118
struct aibuf *b = (void *)((char *)p - offsetof(struct aibuf, ai));
1219
b -= b->slot;
1320
LOCK(b->lock);
1421
if (!(b->ref -= cnt)) free(b);
1522
else UNLOCK(b->lock);
23+
#endif
1624
}

0 commit comments

Comments
 (0)