ff2txt

display a farbfeld(5)-formatted image as braille or ascii text
Log | Files | Refs | README

commit 2f2583b40975087c6463403508706bcc5138e833
parent 84d0d78441e79247fdfb2b5aa937f36709da52dd
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 22 Jan 2018 06:08:28 +0100

fix overflow on non % 4 height

Diffstat:
Mff2braille.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ff2braille.c b/ff2braille.c @@ -90,7 +90,7 @@ int main(void) { struct col buf[MAX_WIDTH * 4], *rows[4]; - uint32_t width, height, r, i; + uint32_t width, height, h, r, i; read_header(&width, &height); if (width == 0 || height == 0) @@ -99,13 +99,13 @@ main(void) for (i = 0; i < 4; i++) rows[i] = buf + width * i; - for (; height > 0; height -= 4) { + for (h = 0; h < height; h += 4) { r = fread(buf, sizeof(*buf), width * 4, stdin); if (r % width != 0) err("invalid line width"); print_4_rows(rows, width, r / width); + if (ferror(stdin)) + err("fread stdin"); } - if (ferror(stdin)) - err("fread stdin"); return 0; }