diff --git a/src/net.cc b/src/net.cc index f17ba834313..347de15a3bf 100644 --- a/src/net.cc +++ b/src/net.cc @@ -435,14 +435,14 @@ Acceptor::v8Listen (const Arguments& args) if (args.Length() < 1) return ThrowException(String::New("Must give at least a port as argument.")); - char *host = NULL; HandleScope scope; String::AsciiValue port(args[0]->ToString()); + char *host = NULL; if (args[1]->IsString()) { String::Utf8Value host_sv(args[1]->ToString()); - host = *host_sv; + host = strdup(*host_sv); } // For servers call getaddrinfo inline. This is blocking but it shouldn't @@ -453,6 +453,8 @@ Acceptor::v8Listen (const Arguments& args) if (r != 0) return ThrowException(String::New(strerror(errno))); + free(host); + acceptor->Listen(address); return Undefined(); }