Browse files

Merge pull request #28 from mpalmer/getaddrinfo-memleak

Free struct addrinfo after use
  • Loading branch information...
2 parents 45da6ba + 357d863 commit ec204c5aaf58d5547db9d1ec5d8244bef84f6a0e @ibc committed Feb 12, 2015
Showing with 5 additions and 2 deletions.
  1. +5 −2 ext/em.cpp
View
7 ext/em.cpp
@@ -1544,12 +1544,15 @@ struct sockaddr *EventMachine_t::name2address (const char *server, int port, int
case AF_INET:
memcpy(&in4, ai->ai_addr, ai->ai_addrlen);
in4.sin_port = htons(port);
- return (struct sockaddr*)&in4;
+#ifndef CYGWIN
case AF_INET6:
memcpy(&in6, ai->ai_addr, ai->ai_addrlen);
in6.sin6_port = htons(port);
- return (struct sockaddr*)&in6;
+#endif
}
+
+ freeaddrinfo(ai);
+ return (struct sockaddr*)&in4;
}
return NULL;

0 comments on commit ec204c5

Please sign in to comment.