Skip to content

Commit

Permalink
Fixed an index out of range if the AbstractLineList reported wrong in…
Browse files Browse the repository at this point in the history
…dex lines
  • Loading branch information
danipen committed Feb 1, 2022
1 parent 079c049 commit 43b77d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/TextMateSharp/Model/AbstractLineList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,27 @@ public void SetModel(TMModel model)

public void AddLine(int line)
{
this.list.Insert(line, new ModelLine());
lock (mLock)
{
this.list.Insert(line, new ModelLine());
}
}

public void RemoveLine(int line)
{
this.list.RemoveAt(line);
lock (mLock)
{
this.list.RemoveAt(line);
}
}

public ModelLine Get(int index)
{
lock (mLock)
{
if (index < 0 || index >= this.list.Count)
return null;

return this.list[index];
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/TextMateSharp/Model/TMModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ void ThreadWorker()
continue;
}

if (model.lines.Get(toProcess).IsInvalid)
var modelLine = model.lines.Get(toProcess);

if (modelLine != null && modelLine.IsInvalid)
{
try
{
Expand Down

0 comments on commit 43b77d5

Please sign in to comment.