Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1a9d7c9 + 9f9df4b commit dbee683Copy full SHA for dbee683
src/posix.c
@@ -62,8 +62,11 @@ int p_getaddrinfo(
62
ai = ainfo;
63
64
for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) {
65
- ai->ai_next = malloc(sizeof(struct addrinfo));
66
- memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo));
+ if (!(ai->ai_next = malloc(sizeof(struct addrinfo)))) {
+ p_freeaddrinfo(ainfo);
67
+ return -1;
68
+ }
69
+ memcpy(ai->ai_next, ainfo, sizeof(struct addrinfo));
70
memcpy(&ai->ai_next->ai_addr_in.sin_addr,
71
ainfo->ai_hostent->h_addr_list[p],
72
ainfo->ai_hostent->h_length);
0 commit comments