Skip to content

Commit 3a896a5

Browse files
committed
Protect resize against NaN and Infinity
Fixes #316
1 parent 74edc71 commit 3a896a5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/unixTerminal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ export class UnixTerminal extends Terminal {
257257
*/
258258

259259
public resize(cols: number, rows: number): void {
260+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
261+
throw new Error('resizing must be done using positive cols and rows');
262+
}
260263
pty.resize(this._fd, cols, rows);
261264
this._cols = cols;
262265
this._rows = rows;

src/windowsTerminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class WindowsTerminal extends Terminal {
142142
*/
143143

144144
public resize(cols: number, rows: number): void {
145-
if (cols <= 0 || rows <= 0) {
145+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
146146
throw new Error('resizing must be done using positive cols and rows');
147147
}
148148
this._defer(() => {

0 commit comments

Comments
 (0)