diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 69ac7fb035..4fb5ca096b 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -107,9 +107,9 @@ class ProcessWrap : public HandleWrap { // options.file Local file_v = js_options->Get(String::New("file")); - if (!file_v.IsEmpty() && file_v->IsString()) { - String::Utf8Value file(file_v->ToString()); - options.file = strdup(*file); + String::Utf8Value file(file_v->IsString() ? file_v : Local()); + if (file.length() > 0) { + options.file = *file; } // options.args @@ -128,11 +128,9 @@ class ProcessWrap : public HandleWrap { // options.cwd Local cwd_v = js_options->Get(String::New("cwd")); - if (!cwd_v.IsEmpty() && cwd_v->IsString()) { - String::Utf8Value cwd(cwd_v->ToString()); - if (cwd.length() > 0) { - options.cwd = strdup(*cwd); - } + String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local()); + if (cwd.length() > 0) { + options.cwd = *cwd; } // options.env @@ -191,9 +189,6 @@ class ProcessWrap : public HandleWrap { delete [] options.args; } - free(options.cwd); - free((void*)options.file); - if (options.env) { for (int i = 0; options.env[i]; i++) free(options.env[i]); delete [] options.env;