Skip to content

Commit 269d772

Browse files
committed
Added error handling to prevent errors writing to screen text buffer past bounds
1 parent 3a2e8ad commit 269d772

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

qb.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,9 +3479,11 @@ var QB = new function() {
34793479
var col = _locX;
34803480
if (_screenText.length < 1 || row >= _screenText.length) { return; }
34813481
for (var i=0; i < text.length; i++) {
3482-
_screenText[row][col+i].text = text.substring(i, i+1);
3483-
_screenText[row][col+i].fgcolor = _fgColor;
3484-
_screenText[row][col+i].bgcolor = _bgColor;
3482+
if (_screenText.length > row && _screenText[row].length > col+i) {
3483+
_screenText[row][col+i].text = text.substring(i, i+1);
3484+
_screenText[row][col+i].fgcolor = _fgColor;
3485+
_screenText[row][col+i].bgcolor = _bgColor;
3486+
}
34853487
}
34863488
}
34873489

0 commit comments

Comments
 (0)