Skip to content

Commit

Permalink
Merge pull request libgit2#3567 from sba1/few-p_getaddrinfo-fixes
Browse files Browse the repository at this point in the history
Few p_getaddrinfo fixes
  • Loading branch information
Edward Thomson committed Feb 29, 2016
2 parents 1a9d7c9 + 9f9df4b commit dbee683
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ int p_getaddrinfo(
ai = ainfo;

for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) {
ai->ai_next = malloc(sizeof(struct addrinfo));
memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo));
if (!(ai->ai_next = malloc(sizeof(struct addrinfo)))) {
p_freeaddrinfo(ainfo);
return -1;
}
memcpy(ai->ai_next, ainfo, sizeof(struct addrinfo));
memcpy(&ai->ai_next->ai_addr_in.sin_addr,
ainfo->ai_hostent->h_addr_list[p],
ainfo->ai_hostent->h_length);
Expand Down

0 comments on commit dbee683

Please sign in to comment.