Skip to content

Commit

Permalink
src: use checked allocations in WASI::New()
Browse files Browse the repository at this point in the history
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Dec 9, 2019
1 parent 25e3696 commit e6e379e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_wasi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
Local<Array> preopens = args[2].As<Array>();
CHECK_EQ(preopens->Length() % 2, 0);
options.preopenc = preopens->Length() / 2;
options.preopens = UncheckedCalloc<uvwasi_preopen_t>(options.preopenc);
options.preopens = Calloc<uvwasi_preopen_t>(options.preopenc);
int index = 0;
for (uint32_t i = 0; i < preopens->Length(); i += 2) {
auto mapped = preopens->Get(context, i).ToLocalChecked();
Expand All @@ -144,7 +144,9 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
node::Utf8Value mapped_path(env->isolate(), mapped);
node::Utf8Value real_path(env->isolate(), real);
options.preopens[index].mapped_path = strdup(*mapped_path);
CHECK_NOT_NULL(options.preopens[index].mapped_path);
options.preopens[index].real_path = strdup(*real_path);
CHECK_NOT_NULL(options.preopens[index].real_path);
index++;
}

Expand Down

0 comments on commit e6e379e

Please sign in to comment.