mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
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 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
90f257176c
commit
298ff4fdb1
|
|
@ -22,7 +22,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Array,
|
|
||||||
NumberIsInteger,
|
NumberIsInteger,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
@ -111,7 +110,7 @@ function WriteStream(fd) {
|
||||||
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
|
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
|
||||||
this._handle.setBlocking(true);
|
this._handle.setBlocking(true);
|
||||||
|
|
||||||
const winSize = new Array(2);
|
const winSize = [0, 0];
|
||||||
const err = this._handle.getWindowSize(winSize);
|
const err = this._handle.getWindowSize(winSize);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
this.columns = winSize[0];
|
this.columns = winSize[0];
|
||||||
|
|
@ -131,7 +130,7 @@ WriteStream.prototype.hasColors = hasColors;
|
||||||
WriteStream.prototype._refreshSize = function() {
|
WriteStream.prototype._refreshSize = function() {
|
||||||
const oldCols = this.columns;
|
const oldCols = this.columns;
|
||||||
const oldRows = this.rows;
|
const oldRows = this.rows;
|
||||||
const winSize = new Array(2);
|
const winSize = [0, 0];
|
||||||
const err = this._handle.getWindowSize(winSize);
|
const err = this._handle.getWindowSize(winSize);
|
||||||
if (err) {
|
if (err) {
|
||||||
this.emit('error', new ErrnoException(err, 'getWindowSize'));
|
this.emit('error', new ErrnoException(err, 'getWindowSize'));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user