Skip to content

Commit 4de7ed4

Browse files
authored
Merge pull request #520 from Tyriar/519_erase_null_check
Add null checks in eraseRight and eraseLeft
2 parents 365a9f9 + 6cd5c2b commit 4de7ed4

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/xterm.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,14 +2159,14 @@ Terminal.prototype.nextStop = function(x) {
21592159
* @param {number} y The line in which to operate.
21602160
*/
21612161
Terminal.prototype.eraseRight = function(x, y) {
2162-
var line = this.lines.get(this.ybase + y)
2163-
, ch = [this.eraseAttr(), ' ', 1]; // xterm
2164-
2165-
2162+
var line = this.lines.get(this.ybase + y);
2163+
if (!line) {
2164+
return;
2165+
}
2166+
var ch = [this.eraseAttr(), ' ', 1]; // xterm
21662167
for (; x < this.cols; x++) {
21672168
line[x] = ch;
21682169
}
2169-
21702170
this.updateRange(y);
21712171
};
21722172

@@ -2178,12 +2178,15 @@ Terminal.prototype.eraseRight = function(x, y) {
21782178
* @param {number} y The line in which to operate.
21792179
*/
21802180
Terminal.prototype.eraseLeft = function(x, y) {
2181-
var line = this.lines.get(this.ybase + y)
2182-
, ch = [this.eraseAttr(), ' ', 1]; // xterm
2183-
2181+
var line = this.lines.get(this.ybase + y);
2182+
if (!line) {
2183+
return;
2184+
}
2185+
var ch = [this.eraseAttr(), ' ', 1]; // xterm
21842186
x++;
2185-
while (x--) line[x] = ch;
2186-
2187+
while (x--) {
2188+
line[x] = ch;
2189+
}
21872190
this.updateRange(y);
21882191
};
21892192

0 commit comments

Comments
 (0)