Skip to content

Commit

Permalink
Be more paranoid about cleaning up escape sequence handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
PerBothner committed Dec 23, 2018
1 parent 29cc0bf commit 48ff841
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/EscapeSequenceParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,17 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
this._errorHandlerFb = null;
this._printHandler = null;
this._executeHandlers = null;
this._csiHandlers = null;
this._escHandlers = null;
let handlers;
while ((handlers = this._csiHandlers) && handlers.dispose !== undefined) {
handlers.dispose();
if (handlers === this._csiHandlers) { break; } // sanity check
}
this._csiHandlers = null;
while ((handlers = this._oscHandlers) && handlers.dispose !== undefined) {
handlers.dispose();
if (handlers === this._oscHandlers) { break; } // sanity check
}
this._oscHandlers = null;
this._dcsHandlers = null;
this._activeDcsHandler = null;
Expand Down Expand Up @@ -319,6 +328,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
if (cur === newHead) {
if (previous) { previous.nextHandler = cur.nextHandler; }
else { handlers[index] = cur.nextHandler; }
cur.nextHandler = null;
handlers = null; newCallback = null; // just in case
break;
}
}
Expand Down

0 comments on commit 48ff841

Please sign in to comment.