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 <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 93ee36e commit a033dff

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎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-
constwinSize=newArray(2);
108+
constwinSize=[0,0];
110109
consterr=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
constoldCols=this.columns;
128127
constoldRows=this.rows;
129-
constwinSize=newArray(2);
128+
constwinSize=[0,0];
130129
consterr=this._handle.getWindowSize(winSize);
131130
if(err){
132131
this.emit('error',newerrors.ErrnoException(err,'getWindowSize'));

0 commit comments

Comments
 (0)