Skip to content

Commit a5e0bf0

Browse files
committed
src: fix null pointer deref error in SetWeak cb
Specifically in `EnvInst::CustomCommandReqWeakCallback()` when trying to access `EnvInst` associated with the `Isolate`. Observed when load-testing the `test/addons/nsolid-custom-command` test.
1 parent 45feced commit a5e0bf0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/nsolid/nsolid_api.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,8 +1962,10 @@ void EnvInst::CustomCommandReqWeakCallback(
19621962
EnvInst* envinst = GetEnvLocalInst(info.GetIsolate());
19631963
std::unique_ptr<CustomCommandGlobalReq> req(info.GetParameter());
19641964
CHECK_NOT_NULL(req);
1965-
ns_mutex::scoped_lock lock(envinst->custom_command_stor_map_lock_);
1966-
envinst->custom_command_stor_map_.erase(req->req_id);
1965+
if (envinst) {
1966+
ns_mutex::scoped_lock lock(envinst->custom_command_stor_map_lock_);
1967+
envinst->custom_command_stor_map_.erase(req->req_id);
1968+
}
19671969
}
19681970

19691971

0 commit comments

Comments
 (0)