Skip to content

Commit

Permalink
timers: fix arbitrary object clearImmediate errors
Browse files Browse the repository at this point in the history
Fix errors that are caused by invoking clearImmediate
with arbitrary objects.

fixes: #37806
  • Loading branch information
Linkgoron committed Mar 20, 2021
1 parent d3417bb commit f0f059f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ ImmediateList.prototype.append = function(item) {
// Removes an item from the linked list, adjusting the pointers of adjacent
// items and the linked list's head or tail pointers as necessary
ImmediateList.prototype.remove = function(item) {
if (item._idleNext !== null) {
if (item._idleNext) {
item._idleNext._idlePrev = item._idlePrev;
}

if (item._idlePrev !== null) {
if (item._idlePrev) {
item._idlePrev._idleNext = item._idleNext;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function clearImmediate(immediate) {
toggleImmediateRef(false);
immediate[kRefed] = null;

if (destroyHooksExist()) {
if (destroyHooksExist() && immediate[async_id_symbol] !== undefined) {
emitDestroy(immediate[async_id_symbol]);
}

Expand Down

0 comments on commit f0f059f

Please sign in to comment.