Skip to content

Commit c2451ee

Browse files
committed
fs: fix return value of fs APIs
1 parent 9c025a9 commit c2451ee

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/node_file-inl.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,24 @@ FSReqBase* GetReqWrap(const v8::FunctionCallbackInfo<v8::Value>& args,
287287
int index,
288288
bool use_bigint) {
289289
v8::Local<v8::Value> value = args[index];
290+
FSReqBase* result = nullptr;
290291
if (value->IsObject()) {
291-
return BaseObject::Unwrap<FSReqBase>(value.As<v8::Object>());
292-
}
293-
294-
Realm* realm = Realm::GetCurrent(args);
295-
BindingData* binding_data = realm->GetBindingData<BindingData>();
296-
297-
if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) {
298-
if (use_bigint) {
299-
return FSReqPromise<AliasedBigInt64Array>::New(binding_data, use_bigint);
300-
} else {
301-
return FSReqPromise<AliasedFloat64Array>::New(binding_data, use_bigint);
292+
result = BaseObject::Unwrap<FSReqBase>(value.As<v8::Object>());
293+
} else {
294+
Realm* realm = Realm::GetCurrent(args);
295+
BindingData* binding_data = realm->GetBindingData<BindingData>();
296+
297+
if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) {
298+
if (use_bigint) {
299+
result = FSReqPromise<AliasedBigInt64Array>::New(binding_data, use_bigint);
300+
} else {
301+
result = FSReqPromise<AliasedFloat64Array>::New(binding_data, use_bigint);
302+
}
302303
}
303304
}
305+
if result != nullptr {
306+
result->SetReturnValue(args);
307+
}
304308
return nullptr;
305309
}
306310

@@ -320,10 +324,7 @@ FSReqBase* AsyncDestCall(Environment* env, FSReqBase* req_wrap,
320324
uv_req->path = nullptr;
321325
after(uv_req); // after may delete req_wrap if there is an error
322326
req_wrap = nullptr;
323-
} else {
324-
req_wrap->SetReturnValue(args);
325327
}
326-
327328
return req_wrap;
328329
}
329330

0 commit comments

Comments
 (0)