Skip to content

Commit

Permalink
Merge pull request #1330 from Dunbaratu/fixes_1289_buf_overrun_in_cmd…
Browse files Browse the repository at this point in the history
…_history

Fixes #1289 (buffer overrun in command history)
  • Loading branch information
erendrake committed Dec 27, 2015
2 parents a5fbb77 + d418adc commit d0a44aa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/kOS.Safe/Screen/ScreenBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ public virtual int ScrollVertical(int deltaRows)
/// in need of a diff check.
/// </summary>
/// <param name="startRow">Starting with this row number</param>
/// <param name="numRows">for this many rows</param>
/// <param name="numRows">for this many rows, or up to the max row the buffer has if this number is too large</param>
public void MarkRowsDirty(int startRow, int numRows)
{
for( int i = 0; i < numRows ; ++i)
// Mark fewer rows than asked to if the reqeusted number would have blown past the end of the buffer:
int numSafeRows = (numRows + startRow <= buffer.Count) ? numRows : buffer.Count - startRow;

for( int i = 0; i < numSafeRows ; ++i)
buffer[startRow + i].TouchTime();
}

Expand Down

0 comments on commit d0a44aa

Please sign in to comment.