Skip to content

Commit e6e379e

Browse files
cjihrigtargos
authored andcommitted
src: use checked allocations in WASI::New()
PR-URL: #30809 Refs: #30257 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: David Carlier <[email protected]>
1 parent 25e3696 commit e6e379e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node_wasi.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
134134
Local<Array> preopens = args[2].As<Array>();
135135
CHECK_EQ(preopens->Length() % 2, 0);
136136
options.preopenc = preopens->Length() / 2;
137-
options.preopens = UncheckedCalloc<uvwasi_preopen_t>(options.preopenc);
137+
options.preopens = Calloc<uvwasi_preopen_t>(options.preopenc);
138138
int index = 0;
139139
for (uint32_t i = 0; i < preopens->Length(); i += 2) {
140140
auto mapped = preopens->Get(context, i).ToLocalChecked();
@@ -144,7 +144,9 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
144144
node::Utf8Value mapped_path(env->isolate(), mapped);
145145
node::Utf8Value real_path(env->isolate(), real);
146146
options.preopens[index].mapped_path = strdup(*mapped_path);
147+
CHECK_NOT_NULL(options.preopens[index].mapped_path);
147148
options.preopens[index].real_path = strdup(*real_path);
149+
CHECK_NOT_NULL(options.preopens[index].real_path);
148150
index++;
149151
}
150152

0 commit comments

Comments
 (0)