Merge remote-tracking branch 'origin/patches-2.0'

This commit is contained in:
Nick Mathewson 2011-04-05 17:19:00 -04:00
commit d7c0ffa1c0

View File

@ -1138,7 +1138,7 @@ apply_numeric_port_hack(int port, struct evutil_addrinfo **ai)
}
}
static void
static int
apply_socktype_protocol_hack(struct evutil_addrinfo *ai)
{
struct evutil_addrinfo *ai_new;
@ -1147,6 +1147,8 @@ apply_socktype_protocol_hack(struct evutil_addrinfo *ai)
if (ai->ai_socktype || ai->ai_protocol)
continue;
ai_new = mm_malloc(sizeof(*ai_new));
if (!ai_new)
return -1;
memcpy(ai_new, ai, sizeof(*ai_new));
ai->ai_socktype = SOCK_STREAM;
ai->ai_protocol = IPPROTO_TCP;
@ -1156,6 +1158,7 @@ apply_socktype_protocol_hack(struct evutil_addrinfo *ai)
ai_new->ai_next = ai->ai_next;
ai->ai_next = ai_new;
}
return 0;
}
#endif
@ -1246,7 +1249,11 @@ evutil_getaddrinfo(const char *nodename, const char *servname,
apply_numeric_port_hack(portnum, res);
if (need_socktype_protocol_hack()) {
apply_socktype_protocol_hack(*res);
if (apply_socktype_protocol_hack(*res) < 0) {
evutil_freeaddrinfo(*res);
*res = NULL;
return EVUTIL_EAI_MEMORY;
}
}
return err;
#else