Skip to content

Commit

Permalink
Protect resize against NaN and Infinity
Browse files Browse the repository at this point in the history
Fixes #316
  • Loading branch information
Tyriar committed Oct 22, 2019
1 parent 74edc71 commit 3a896a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/windowsTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 3a896a5

Please sign in to comment.