From e0ef43414ef8d8a387d70641670c9ac86cc7efb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 9 Aug 2024 08:16:26 +0200 Subject: [PATCH 1/2] tty: initialize winSize array with values Assigning to a holey array in the native layer may crash if it has getters that throw. Refs: https://github.com/nodejs/node/issues/54186 --- lib/tty.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tty.js b/lib/tty.js index 1a3fa5afe53a41..ba4cebb92cd933 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -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]; @@ -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')); From e3b3a022e2431f54600a68d08118188f48308efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 9 Aug 2024 08:22:58 +0200 Subject: [PATCH 2/2] fixup! tty: initialize winSize array with values --- lib/tty.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tty.js b/lib/tty.js index ba4cebb92cd933..b1a2d3e7a9bc4d 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -22,7 +22,6 @@ 'use strict'; const { - Array, NumberIsInteger, ObjectSetPrototypeOf, } = primordials;