process: don't use strdup()
file and cwd can be directly used from Utf8Value. Conflicts: src/process_wrap.cc
This commit is contained in:
parent
3546383cf0
commit
db844b152a
@ -139,9 +139,9 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
// options.file
|
// options.file
|
||||||
Local<Value> file_v = js_options->Get(String::NewSymbol("file"));
|
Local<Value> file_v = js_options->Get(String::NewSymbol("file"));
|
||||||
if (!file_v.IsEmpty() && file_v->IsString()) {
|
String::Utf8Value file(file_v->IsString() ? file_v : Local<Value>());
|
||||||
String::Utf8Value file(file_v->ToString());
|
if (file.length() > 0) {
|
||||||
options.file = strdup(*file);
|
options.file = *file;
|
||||||
} else {
|
} else {
|
||||||
return ThrowException(Exception::TypeError(String::New("Bad argument")));
|
return ThrowException(Exception::TypeError(String::New("Bad argument")));
|
||||||
}
|
}
|
||||||
@ -162,11 +162,9 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
// options.cwd
|
// options.cwd
|
||||||
Local<Value> cwd_v = js_options->Get(String::NewSymbol("cwd"));
|
Local<Value> cwd_v = js_options->Get(String::NewSymbol("cwd"));
|
||||||
if (!cwd_v.IsEmpty() && cwd_v->IsString()) {
|
String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>());
|
||||||
String::Utf8Value cwd(cwd_v->ToString());
|
|
||||||
if (cwd.length() > 0) {
|
if (cwd.length() > 0) {
|
||||||
options.cwd = strdup(*cwd);
|
options.cwd = *cwd;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// options.env
|
// options.env
|
||||||
@ -228,9 +226,6 @@ class ProcessWrap : public HandleWrap {
|
|||||||
delete [] options.args;
|
delete [] options.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(options.cwd);
|
|
||||||
free((void*)options.file);
|
|
||||||
|
|
||||||
if (options.env) {
|
if (options.env) {
|
||||||
for (int i = 0; options.env[i]; i++) free(options.env[i]);
|
for (int i = 0; options.env[i]; i++) free(options.env[i]);
|
||||||
delete [] options.env;
|
delete [] options.env;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user