Skip to content

Commit

Permalink
tty: initialize winSize array with values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
targos committed Oct 2, 2024
1 parent 93ee36e commit a033dff
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
'use strict';

const {
Array,
NumberIsInteger,
ObjectSetPrototypeOf,
} = primordials;
Expand Down Expand Up @@ -106,7 +105,7 @@ function WriteStream(fd) {
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
this._handle.setBlocking(true);

const winSize = new Array(2);
const winSize = [0, 0];
const err = this._handle.getWindowSize(winSize);
if (!err) {
this.columns = winSize[0];
Expand All @@ -126,7 +125,7 @@ WriteStream.prototype.hasColors = hasColors;
WriteStream.prototype._refreshSize = function() {
const oldCols = this.columns;
const oldRows = this.rows;
const winSize = new Array(2);
const winSize = [0, 0];
const err = this._handle.getWindowSize(winSize);
if (err) {
this.emit('error', new errors.ErrnoException(err, 'getWindowSize'));
Expand Down

0 comments on commit a033dff

Please sign in to comment.