Skip to content

Commit 2a952b3

Browse files
authored
wasi_socket_ext.c: fix the number of getaddrinfo results (#4466)
the case of zero results was especially broken.
1 parent b3158e6 commit 2a952b3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
541541
}
542542
} while (max_info_size > addr_info_size);
543543

544+
addr_info_size = max_info_size;
544545
if (addr_info_size == 0) {
545546
free(addr_info);
546-
*res = NULL;
547-
return __WASI_ERRNO_SUCCESS;
547+
HANDLE_ERROR(__WASI_ERRNO_NOENT)
548548
}
549549

550550
aibuf_res =
@@ -556,10 +556,6 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
556556

557557
*res = &aibuf_res[0].ai;
558558

559-
if (addr_info_size) {
560-
addr_info_size = max_info_size;
561-
}
562-
563559
for (i = 0; i < addr_info_size; i++) {
564560
struct addrinfo *ai = &aibuf_res[i].ai;
565561
ai->ai_addr = (struct sockaddr *)&aibuf_res[i].sa;

0 commit comments

Comments
 (0)