From 273456b010fdad4179befc4e76d90c07846667e4 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 8 Mar 2018 17:05:43 +0200 Subject: starpbm: Add assert for overflow --- src/bin/starpbm.c | 1 + 1 file changed, 1 insertion(+) 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); } -- cgit v1.2.3-70-g09d2