wdvi

network DVI viewer
Log | Files | Refs

commit 9f969b55ac46c1ccfec2e3cb72b4d23283640251
parent 369f9d93ac8362c71cec2d319b4c94067d339160
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Fri, 17 Sep 2021 20:14:31 +0000

check for errors in fseek()

Diffstat:
Mdvi-draw.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/dvi-draw.c b/dvi-draw.c @@ -175,9 +175,6 @@ put_image(g, x, y) * Byte reading routines for dvi file. */ -#define xtell(pos) (fseek(dvi_file, 0L, SEEK_CUR) - \ - (currinf.end - (pos))) - static ubyte xxone() { @@ -239,6 +236,7 @@ tell_oops(const char *message, ...) if (currinf.virtual) warnx("in virtual font '%s'", currinf.virtual->fontname); else +#define xtell(pos) (ftell(dvi_file) - (currinf.end - (pos))) warnx("offset %ld", xtell(currinf.pos - 1)); exit(1); } @@ -649,7 +647,8 @@ prescan(void) int nextreportpage; nextreportpage = scanned_page; - fseek(dvi_file, page_info[scanned_page + 1].offset, SEEK_SET); + if (fseek(dvi_file, page_info[scanned_page + 1].offset, SEEK_SET) != 0) + err(1, "fseek"); currinf.pos = currinf.end = dvi_buffer; for (;;) { @@ -702,7 +701,8 @@ set_char(wide_ubyte ch) if (currinf.fontp->ft == NULL) /* if not freetype font */ { open_font_file(currinf.fontp); - fseek(currinf.fontp->file, g->addr, 0); + if (fseek(currinf.fontp->file, g->addr, SEEK_SET) != 0) + err(1, "fseek"); } (*currinf.fontp->read_char)(currinf.fontp, ch); if (debug & DBG_BITMAP) print_char((ubyte) ch, g); @@ -1081,8 +1081,7 @@ draw_page() rcs_top = NULL; set_fg_color(&color_bottom[color_bot_size - 1]); - (void) fseek(dvi_file, page_info[current_page].offset, - SEEK_SET); + (void) fseek(dvi_file, page_info[current_page].offset, SEEK_SET); bzero((char *) &currinf.data, sizeof currinf.data); currinf.tn_table_len = TNTABLELEN; @@ -1204,7 +1203,8 @@ geom_do_char(g_info, ch) if (currinf.fontp->ft == NULL) { open_font_file(currinf.fontp); - fseek(currinf.fontp->file, g->addr, 0); + if (fseek(currinf.fontp->file, g->addr, SEEK_SET) != 0) + err(1, "fseek"); } (*currinf.fontp->read_char)(currinf.fontp, ch); if (debug & DBG_BITMAP) print_char((ubyte) ch, g);