From db844b152a92bcc02c20e62ea85958c0f3dfc532 Mon Sep 17 00:00:00 2001 From: ssuda Date: Tue, 20 Mar 2012 21:09:49 +0530 Subject: [PATCH] process: don't use strdup() file and cwd can be directly used from Utf8Value. Conflicts: src/process_wrap.cc --- src/process_wrap.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 39ebb054fc..4a434377c6 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -139,9 +139,9 @@ class ProcessWrap : public HandleWrap { // options.file Local file_v = js_options->Get(String::NewSymbol("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; } else { return ThrowException(Exception::TypeError(String::New("Bad argument"))); } @@ -162,12 +162,10 @@ class ProcessWrap : public HandleWrap { // options.cwd Local cwd_v = js_options->Get(String::NewSymbol("cwd")); - if (!cwd_v.IsEmpty() && cwd_v->IsString()) { - String::Utf8Value cwd(cwd_v->ToString()); + String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local()); if (cwd.length() > 0) { - options.cwd = strdup(*cwd); + options.cwd = *cwd; } - } // options.env Local env_v = js_options->Get(String::NewSymbol("envPairs")); @@ -228,9 +226,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;