From 3ed77dbb2e8db2b901e9e0c22dbb72104fd963c5 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Mon, 10 Feb 2020 00:18:08 -0500 Subject: [PATCH] Sanitize inputs to insert and remove --- internal/buffer/eventhandler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/buffer/eventhandler.go b/internal/buffer/eventhandler.go index cc737586..9e57108d 100644 --- a/internal/buffer/eventhandler.go +++ b/internal/buffer/eventhandler.go @@ -117,6 +117,7 @@ func (eh *EventHandler) Insert(start Loc, textStr string) { // InsertBytes creates an insert text event and executes it func (eh *EventHandler) InsertBytes(start Loc, text []byte) { + start = clamp(start, eh.buf.LineArray) e := &TextEvent{ C: *eh.cursors[eh.active], EventType: TextEventInsert, @@ -167,6 +168,8 @@ func (eh *EventHandler) InsertBytes(start Loc, text []byte) { // Remove creates a remove text event and executes it func (eh *EventHandler) Remove(start, end Loc) { + start = clamp(start, eh.buf.LineArray) + end = clamp(end, eh.buf.LineArray) e := &TextEvent{ C: *eh.cursors[eh.active], EventType: TextEventRemove,