Skip to content

Commit 9f798de

Browse files
tniessenrichardlau
authored andcommitted
src: fix order of CHECK_NOT_NULL/dereference
`ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS` may dereference `req_wrap_async`, so `CHECK_NOT_NULL(req_wrap_async)` should be used before and not after. PR-URL: #59487 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ulises Gascón <[email protected]>
1 parent 312bc4e commit 9f798de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,12 +1562,12 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
15621562

15631563
if (argc > 1) { // unlink(path, req)
15641564
FSReqBase* req_wrap_async = GetReqWrap(args, 1);
1565+
CHECK_NOT_NULL(req_wrap_async);
15651566
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
15661567
env,
15671568
req_wrap_async,
15681569
permission::PermissionScope::kFileSystemWrite,
15691570
path.ToStringView());
1570-
CHECK_NOT_NULL(req_wrap_async);
15711571
FS_ASYNC_TRACE_BEGIN1(
15721572
UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path))
15731573
AsyncCall(env, req_wrap_async, args, "unlink", UTF8, AfterNoArgs,

0 commit comments

Comments
 (0)