Do a bounds check for charpos function

This commit is contained in:
Zachary Yedidia
2016-05-24 09:15:01 -04:00
parent 55a6b6701d
commit f730864e9f

View File

@@ -18,6 +18,9 @@ func FromCharPosStart(startLoc, startX, startY, loc int, buf *Buffer) (int, int)
for charNum+lineLen <= loc {
charNum += lineLen
y++
if y >= buf.NumLines {
return 0, 0
}
lineLen = Count(buf.Lines[y]) + 1
}
x = loc - charNum