Skip to content

Commit 298ff4f

Browse files
authored
tty: initialize winSize array with values
Assigning to a holey array in the native layer may crash if it has getters that throw. Refs: #54186 PR-URL: #54281 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 90f2571 commit 298ff4f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/tty.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'use strict';
2323

2424
const {
25-
Array,
2625
NumberIsInteger,
2726
ObjectSetPrototypeOf,
2827
} = primordials;
@@ -111,7 +110,7 @@ function WriteStream(fd) {
111110
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
112111
this._handle.setBlocking(true);
113112

114-
const winSize = new Array(2);
113+
const winSize = [0, 0];
115114
const err = this._handle.getWindowSize(winSize);
116115
if (!err) {
117116
this.columns = winSize[0];
@@ -131,7 +130,7 @@ WriteStream.prototype.hasColors = hasColors;
131130
WriteStream.prototype._refreshSize = function() {
132131
const oldCols = this.columns;
133132
const oldRows = this.rows;
134-
const winSize = new Array(2);
133+
const winSize = [0, 0];
135134
const err = this._handle.getWindowSize(winSize);
136135
if (err) {
137136
this.emit('error', new ErrnoException(err, 'getWindowSize'));

0 commit comments

Comments
 (0)