diff --git a/src/unixTerminal.ts b/src/unixTerminal.ts index 44a3383dc..58e45677e 100644 --- a/src/unixTerminal.ts +++ b/src/unixTerminal.ts @@ -257,6 +257,9 @@ export class UnixTerminal extends Terminal { */ public resize(cols: number, rows: number): void { + if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) { + throw new Error('resizing must be done using positive cols and rows'); + } pty.resize(this._fd, cols, rows); this._cols = cols; this._rows = rows; diff --git a/src/windowsTerminal.ts b/src/windowsTerminal.ts index 4890d202b..5deb224f5 100644 --- a/src/windowsTerminal.ts +++ b/src/windowsTerminal.ts @@ -142,7 +142,7 @@ export class WindowsTerminal extends Terminal { */ public resize(cols: number, rows: number): void { - if (cols <= 0 || rows <= 0) { + if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) { throw new Error('resizing must be done using positive cols and rows'); } this._defer(() => {