Skip to content

Commit 049a172

Browse files
addaleaxcodebytere
authored andcommitted
src: harden running native SetImmediate()s slightly
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 <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 5656ec9 commit 049a172

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/env.cc

+2
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
701701
if (head->is_refed() || !only_refed)
702702
head->Call(this);
703703

704+
head.reset(); // Destroy now so that this is also observed by try_catch.
705+
704706
if (UNLIKELY(try_catch.HasCaught())) {
705707
if (!try_catch.HasTerminated() && can_call_into_js())
706708
errors::TriggerUncaughtException(isolate(), try_catch);

0 commit comments

Comments
 (0)