Avoid a potentially invalid LargeConsoleRead line.

I think it might be possible for m_dirtyLineCount to be greater than the
windowRect.top() + windowRect.height().  If it is, then scanForDirtyLines
will perform an invalid read while trying to initialize prevLineAttr.
This commit is contained in:
Ryan Prichard 2015-11-06 02:25:08 -06:00
parent 24dd41bb79
commit 70eafd08d3

View File

@ -708,7 +708,8 @@ void Agent::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info)
// necessary so long as the cursor is inside the current window.)
const int firstReadLine = std::min(firstVirtLine - m_scrolledCount,
m_dirtyLineCount - 1);
const int stopReadLine = windowRect.top() + windowRect.height();
const int stopReadLine = std::max(windowRect.top() + windowRect.height(),
m_dirtyLineCount);
ASSERT(firstReadLine >= 0 && stopReadLine > firstReadLine);
largeConsoleRead(m_readBuffer,
*m_console,