Skip to content

Commit

Permalink
src: harden running native SetImmediate()s slightly
Browse files Browse the repository at this point in the history
Prevent mistakes like the one fixed by the previous commit
by destroying the callback immediately after it has been called.

PR-URL: #31468
Refs: #31386
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
addaleax authored and codebytere committed Feb 17, 2020
1 parent 5656ec9 commit 049a172
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
if (head->is_refed() || !only_refed)
head->Call(this);

head.reset(); // Destroy now so that this is also observed by try_catch.

if (UNLIKELY(try_catch.HasCaught())) {
if (!try_catch.HasTerminated() && can_call_into_js())
errors::TriggerUncaughtException(isolate(), try_catch);
Expand Down

0 comments on commit 049a172

Please sign in to comment.