summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 3f25142..c440ed4 100644
--- a/buffer.c
+++ b/buffer.c
@@ -308,6 +308,9 @@ bool buffer_indent_with_spaces(TextBuffer *buffer) {
}
String32 buffer_get_line(TextBuffer *buffer, u32 line_number) {
+ if (line_number >= buffer->nlines) {
+ return str32(NULL, 0);
+ }
Line *line = &buffer->lines[line_number];
return (String32) {
.str = line->str, .len = line->len