summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 28ec364..b016d9e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1249,6 +1249,8 @@ static Status buffer_insert_lines(TextBuffer *buffer, u32 where, u32 number) {
// inserts the given text, returning the position of the end of the text
BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32 str) {
+ buffer_pos_validate(buffer, &pos);
+
if (buffer->view_only)
return pos;
if (str.len > U32_MAX) {
@@ -1480,6 +1482,8 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_)
if (nchars_ > U32_MAX) nchars_ = U32_MAX;
u32 nchars = (u32)nchars_;
+ buffer_pos_validate(buffer, &pos);
+
// Correct nchars in case it goes past the end of the file.
// Why do we need to correct it?
// When generating undo events, we allocate nchars characters of memory (see buffer_edit below).