From b098e5225ae2fe7d99b3f99bb5aebcefd9731f96 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 19 Dec 2020 18:42:13 -0800 Subject: Extra safety --- file_loader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/file_loader.c b/file_loader.c index ab677a1..72cea72 100644 --- a/file_loader.c +++ b/file_loader.c @@ -135,6 +135,10 @@ const char *get_line(file_t *f, size_t line_number) void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, const char *fmt, ...) { + if (start < f->contents) start = f->contents; + if (start > f->end) start = f->end; + if (end < f->contents) end = f->contents; + if (end > f->end) end = f->end; size_t linenum = get_line_number(f, start); const char *line = get_line(f, linenum); size_t charnum = get_char_number(f, start); -- cgit v1.2.3