Skip to content

Commit 43b77d5

Browse files
committed
Fixed an index out of range if the AbstractLineList reported wrong index lines
1 parent 079c049 commit 43b77d5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/TextMateSharp/Model/AbstractLineList.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,27 @@ public void SetModel(TMModel model)
2222

2323
public void AddLine(int line)
2424
{
25-
this.list.Insert(line, new ModelLine());
25+
lock (mLock)
26+
{
27+
this.list.Insert(line, new ModelLine());
28+
}
2629
}
2730

2831
public void RemoveLine(int line)
2932
{
30-
this.list.RemoveAt(line);
33+
lock (mLock)
34+
{
35+
this.list.RemoveAt(line);
36+
}
3137
}
3238

3339
public ModelLine Get(int index)
3440
{
3541
lock (mLock)
3642
{
43+
if (index < 0 || index >= this.list.Count)
44+
return null;
45+
3746
return this.list[index];
3847
}
3948
}

src/TextMateSharp/Model/TMModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ void ThreadWorker()
9494
continue;
9595
}
9696

97-
if (model.lines.Get(toProcess).IsInvalid)
97+
var modelLine = model.lines.Get(toProcess);
98+
99+
if (modelLine != null && modelLine.IsInvalid)
98100
{
99101
try
100102
{

0 commit comments

Comments
 (0)