Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
targos committed Aug 9, 2024
commit e0ef43414ef8d8a387d70641670c9ac86cc7efb7
4 changes: 2 additions & 2 deletions lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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 @@ -131,7 +131,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 ErrnoException(err, 'getWindowSize'));
Expand Down