summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-03-08 17:05:43 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-03-08 17:05:43 +0200
commit273456b010fdad4179befc4e76d90c07846667e4 (patch)
tree634316e536c05d27329de3c8029ab6c7533f80c7 /src
parent159344852921967140b44de91e1eb717f23f6cde (diff)
starpbm: Add assert for overflow
Diffstat (limited to 'src')
-rw-r--r--src/bin/starpbm.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/bin/starpbm.c b/src/bin/starpbm.c
index fd3f235..ba4e46d 100644
--- a/src/bin/starpbm.c
+++ b/src/bin/starpbm.c
@@ -140,6 +140,7 @@ main(int argc, char *argv[])
}
const size_t pos = (last_black - &pixels[y * w]) + 1;
+ assert(y * w + pos <= w * h);
fprintf(output, "b%c%c", (char)(pos % 256), (char)(pos / 256));
fwrite(&pixels[y * w], 1, pos, output);
}