diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-12-19 18:42:13 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-12-19 18:42:13 -0800 |
| commit | b098e5225ae2fe7d99b3f99bb5aebcefd9731f96 (patch) | |
| tree | 62cf0b1a53abd95f4bcc3e7a0716e7422db8b7e3 | |
| parent | 06b1a795bb10dd8ed9c2f406ca3b906917e1a106 (diff) | |
Extra safety
| -rw-r--r-- | file_loader.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |
