fixed leak in host_create_from_string("%any")

This commit is contained in:
Martin Willi
2008-11-10 16:42:05 +00:00
parent ae42288a81
commit f821bfb2b3
+4 -3
View File
@@ -392,13 +392,15 @@ static private_host_t *host_create_empty(void)
*/ */
host_t *host_create_from_string(char *string, u_int16_t port) host_t *host_create_from_string(char *string, u_int16_t port)
{ {
private_host_t *this = host_create_empty(); private_host_t *this;
if (streq(string, "%any")) if (streq(string, "%any"))
{ {
return host_create_any(AF_INET); return host_create_any(AF_INET);
} }
else if (strchr(string, '.'))
this = host_create_empty();
if (strchr(string, '.'))
{ {
this->address.sa_family = AF_INET; this->address.sa_family = AF_INET;
} }
@@ -406,7 +408,6 @@ host_t *host_create_from_string(char *string, u_int16_t port)
{ {
this->address.sa_family = AF_INET6; this->address.sa_family = AF_INET6;
} }
switch (this->address.sa_family) switch (this->address.sa_family)
{ {
case AF_INET: case AF_INET: