File tree 1 file changed +5
-10
lines changed
1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,9 @@ class ProcessWrap : public HandleWrap {
139
139
140
140
// options.file
141
141
Local<Value> file_v = js_options->Get (String::NewSymbol (" file" ));
142
- if (! file_v. IsEmpty () && file_v-> IsString ()) {
143
- String::Utf8Value file (file_v-> ToString ());
144
- options.file = strdup ( *file) ;
142
+ String::Utf8Value file ( file_v-> IsString () ? file_v : Local<Value> ());
143
+ if ( file. length () > 0 ) {
144
+ options.file = *file;
145
145
} else {
146
146
return ThrowException (Exception::TypeError (String::New (" Bad argument" )));
147
147
}
@@ -162,12 +162,10 @@ class ProcessWrap : public HandleWrap {
162
162
163
163
// options.cwd
164
164
Local<Value> cwd_v = js_options->Get (String::NewSymbol (" cwd" ));
165
- if (!cwd_v.IsEmpty () && cwd_v->IsString ()) {
166
- String::Utf8Value cwd (cwd_v->ToString ());
165
+ String::Utf8Value cwd (cwd_v->IsString () ? cwd_v : Local<Value>());
167
166
if (cwd.length () > 0 ) {
168
- options.cwd = strdup ( *cwd) ;
167
+ options.cwd = *cwd;
169
168
}
170
- }
171
169
172
170
// options.env
173
171
Local<Value> env_v = js_options->Get (String::NewSymbol (" envPairs" ));
@@ -228,9 +226,6 @@ class ProcessWrap : public HandleWrap {
228
226
delete [] options.args ;
229
227
}
230
228
231
- free (options.cwd );
232
- free ((void *)options.file );
233
-
234
229
if (options.env ) {
235
230
for (int i = 0 ; options.env [i]; i++) free (options.env [i]);
236
231
delete [] options.env ;
You can’t perform that action at this time.
0 commit comments