Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

process: don't use strdup()

file and cwd can be directly used from Utf8Value.
  • Loading branch information...
commit 253ec6a63dddbf13bea391a765fceada03a94d0f 1 parent 415bff2
ssuda authored bnoordhuis committed
Showing with 6 additions and 11 deletions.
  1. +6 −11 src/process_wrap.cc
View
17 src/process_wrap.cc
@@ -107,9 +107,9 @@ class ProcessWrap : public HandleWrap {
// options.file
Local<Value> 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<Value>());
+ if (file.length() > 0) {
+ options.file = *file;
}
// options.args
@@ -128,11 +128,9 @@ class ProcessWrap : public HandleWrap {
// options.cwd
Local<Value> 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<Value>());
+ 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;
Please sign in to comment.
Something went wrong with that request. Please try again.