diff --git a/lib/fs.js b/lib/fs.js index f761d75de89118..8080c6ac756191 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -518,7 +518,7 @@ function close(fd, callback = defaultCloseCallback) { const req = new FSReqCallback(); req.oncomplete = callback; - binding.close(getValidatedFd(fd), req); + binding.close(fd, req); } /** @@ -527,7 +527,7 @@ function close(fd, callback = defaultCloseCallback) { * @returns {void} */ function closeSync(fd) { - binding.close(getValidatedFd(fd)); + binding.close(fd); } /** diff --git a/src/node_file.cc b/src/node_file.cc index 33cd3be670619b..4236debfc70ede 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -984,8 +984,10 @@ void Close(const FunctionCallbackInfo& args) { const int argc = args.Length(); CHECK_GE(argc, 1); - CHECK(args[0]->IsInt32()); - int fd = args[0].As()->Value(); + int fd; + if (!GetValidatedFd(env, args[0]).To(&fd)) { + return; + } env->RemoveUnmanagedFd(fd); if (argc > 1) { // close(fd, req)