Skip to content

Commit 70b2e94

Browse files
authoredOct 22, 2019
Merge pull request #363 from microsoft/protect_resize
Protect resize against NaN and Infinity
2 parents 74edc71 + 3a896a5 commit 70b2e94

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎src/unixTerminal.ts

+3
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

+1-1
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)
Please sign in to comment.