diff --git a/src/node_file.cc b/src/node_file.cc index 2a2384c88c63d7..8c2a902ed83b78 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1143,6 +1143,7 @@ static void LStat(const FunctionCallbackInfo& args) { bool use_bigint = args[1]->IsTrue(); if (!args[2]->IsUndefined()) { // lstat(path, use_bigint, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_LSTAT, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "lstat", UTF8, AfterStat, @@ -1185,6 +1186,7 @@ static void FStat(const FunctionCallbackInfo& args) { bool use_bigint = args[1]->IsTrue(); if (!args[2]->IsUndefined()) { // fstat(fd, use_bigint, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_FSTAT, req_wrap_async) AsyncCall(env, req_wrap_async, args, "fstat", UTF8, AfterStat, uv_fs_fstat, fd); @@ -1286,6 +1288,7 @@ static void Symlink(const FunctionCallbackInfo& args) { if (argc > 3) { // symlink(target, path, flags, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN2(UV_FS_SYMLINK, req_wrap_async, "target", @@ -1324,6 +1327,7 @@ static void Link(const FunctionCallbackInfo& args) { if (argc > 2) { // link(src, dest, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); // To avoid bypass the link target should be allowed to read and write ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, @@ -1382,6 +1386,7 @@ static void ReadLink(const FunctionCallbackInfo& args) { if (argc > 2) { // readlink(path, encoding, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_READLINK, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "readlink", encoding, AfterStringPtr, @@ -1422,6 +1427,7 @@ static void Rename(const FunctionCallbackInfo& args) { if (argc > 2) { // rename(old_path, new_path, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async, @@ -1479,6 +1485,7 @@ static void FTruncate(const FunctionCallbackInfo& args) { if (argc > 2) { // ftruncate(fd, len, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_FTRUNCATE, req_wrap_async) AsyncCall(env, req_wrap_async, args, "ftruncate", UTF8, AfterNoArgs, uv_fs_ftruncate, fd, len); @@ -1588,6 +1595,7 @@ static void RMDir(const FunctionCallbackInfo& args) { if (argc > 1) { FSReqBase* req_wrap_async = GetReqWrap(args, 1); // rmdir(path, req) + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_RMDIR, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "rmdir", UTF8, AfterNoArgs, @@ -1885,6 +1893,7 @@ static void MKDir(const FunctionCallbackInfo& args) { if (argc > 3) { // mkdir(path, mode, recursive, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "mkdir", UTF8, @@ -1931,6 +1940,7 @@ static void RealPath(const FunctionCallbackInfo& args) { if (argc > 2) { // realpath(path, encoding, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_REALPATH, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "realpath", encoding, AfterStringPtr, @@ -1992,6 +2002,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { if (argc > 3) { // readdir(path, encoding, withTypes, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async, @@ -2239,6 +2250,7 @@ static void CopyFile(const FunctionCallbackInfo& args) { if (argc > 3) { // copyFile(src, dest, flags, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async, @@ -2374,6 +2386,7 @@ static void WriteBuffers(const FunctionCallbackInfo& args) { if (argc > 3) { // writeBuffers(fd, chunks, pos, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_WRITE, req_wrap_async) AsyncCall(env, req_wrap_async, @@ -2758,6 +2771,7 @@ static void ReadBuffers(const FunctionCallbackInfo& args) { if (argc > 3) { // readBuffers(fd, buffers, pos, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_READ, req_wrap_async) AsyncCall(env, req_wrap_async, args, "read", UTF8, AfterInteger, uv_fs_read, fd, *iovs, iovs.length(), pos); @@ -2795,6 +2809,7 @@ static void Chmod(const FunctionCallbackInfo& args) { if (argc > 2) { // chmod(path, mode, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_CHMOD, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "chmod", UTF8, AfterNoArgs, @@ -2827,6 +2842,7 @@ static void FChmod(const FunctionCallbackInfo& args) { if (argc > 2) { // fchmod(fd, mode, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHMOD, req_wrap_async) AsyncCall(env, req_wrap_async, args, "fchmod", UTF8, AfterNoArgs, uv_fs_fchmod, fd, mode); @@ -2904,6 +2920,7 @@ static void FChown(const FunctionCallbackInfo& args) { if (argc > 3) { // fchown(fd, uid, gid, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHOWN, req_wrap_async) AsyncCall(env, req_wrap_async, args, "fchown", UTF8, AfterNoArgs, uv_fs_fchown, fd, uid, gid); @@ -2934,6 +2951,7 @@ static void LChown(const FunctionCallbackInfo& args) { if (argc > 3) { // lchown(path, uid, gid, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async, @@ -2976,6 +2994,7 @@ static void UTimes(const FunctionCallbackInfo& args) { if (argc > 3) { // utimes(path, atime, mtime, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_UTIME, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "utime", UTF8, AfterNoArgs, @@ -3008,6 +3027,7 @@ static void FUTimes(const FunctionCallbackInfo& args) { if (argc > 3) { // futimes(fd, atime, mtime, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN0(UV_FS_FUTIME, req_wrap_async) AsyncCall(env, req_wrap_async, args, "futime", UTF8, AfterNoArgs, uv_fs_futime, fd, atime, mtime); @@ -3040,6 +3060,7 @@ static void LUTimes(const FunctionCallbackInfo& args) { if (argc > 3) { // lutimes(path, atime, mtime, req) FSReqBase* req_wrap_async = GetReqWrap(args, 3); + CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_LUTIME, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "lutime", UTF8, AfterNoArgs, @@ -3072,6 +3093,7 @@ static void Mkdtemp(const FunctionCallbackInfo& args) { if (argc > 2) { // mkdtemp(tmpl, encoding, req) FSReqBase* req_wrap_async = GetReqWrap(args, 2); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async,