Skip to content

Commit a033dff

Browse files
committed
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 93ee36e commit a033dff

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/tty.js

Lines changed: 2 additions & 3 deletions
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;
@@ -106,7 +105,7 @@ function WriteStream(fd) {
106105
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
107106
this._handle.setBlocking(true);
108107

109-
const winSize = new Array(2);
108+
const winSize = [0, 0];
110109
const err = this._handle.getWindowSize(winSize);
111110
if (!err) {
112111
this.columns = winSize[0];
@@ -126,7 +125,7 @@ WriteStream.prototype.hasColors = hasColors;
126125
WriteStream.prototype._refreshSize = function() {
127126
const oldCols = this.columns;
128127
const oldRows = this.rows;
129-
const winSize = new Array(2);
128+
const winSize = [0, 0];
130129
const err = this._handle.getWindowSize(winSize);
131130
if (err) {
132131
this.emit('error', new errors.ErrnoException(err, 'getWindowSize'));

0 commit comments

Comments
 (0)