Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
process: don't use strdup()
file and cwd can be directly used from Utf8Value.

Conflicts:

	src/process_wrap.cc
  • Loading branch information
ssuda authored and piscisaureus committed Apr 28, 2012
1 parent 3546383 commit db844b1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/process_wrap.cc
Expand Up @@ -139,9 +139,9 @@ class ProcessWrap : public HandleWrap {

// options.file
Local<Value> 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<Value>());
if (file.length() > 0) {
options.file = *file;
} else {
return ThrowException(Exception::TypeError(String::New("Bad argument")));
}
Expand All @@ -162,12 +162,10 @@ class ProcessWrap : public HandleWrap {

// options.cwd
Local<Value> 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<Value>());
if (cwd.length() > 0) {
options.cwd = strdup(*cwd);
options.cwd = *cwd;
}
}

// options.env
Local<Value> env_v = js_options->Get(String::NewSymbol("envPairs"));
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit db844b1

Please sign in to comment.