fix overflow on non % 4 height - ff2txt - farbfeld image to plain text visualization
HTML git clone git://bitreich.org/ff2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ff2txt
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit 2f2583b40975087c6463403508706bcc5138e833
DIR parent 84d0d78441e79247fdfb2b5aa937f36709da52dd
HTML Author: Josuah Demangeon <mail@josuah.net>
Date: Mon, 22 Jan 2018 06:08:28 +0100
fix overflow on non % 4 height
Diffstat:
M ff2braille.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
DIR 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;
}