From a6b0734fe814425d2d3638e313b3102327064185 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 11 Jan 2022 08:11:36 -0800 Subject: [PATCH] Prevent exception being thrown in reflow smaller Fixes #3602 --- src/common/buffer/Buffer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/buffer/Buffer.ts b/src/common/buffer/Buffer.ts index c788bf36..f927cc8e 100644 --- a/src/common/buffer/Buffer.ts +++ b/src/common/buffer/Buffer.ts @@ -367,6 +367,11 @@ export class Buffer implements IBuffer { let srcCol = lastLineLength; while (srcLineIndex >= 0) { const cellsToCopy = Math.min(srcCol, destCol); + if (wrappedLines[destLineIndex] === undefined) { + // Sanity check that the line exists, this has been known to fail for an unknown reason + // which would stop the reflow from happening if an exception would throw. + break; + } wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true); destCol -= cellsToCopy; if (destCol === 0) {