From 5e031095fd01f98b7cd872aaa032dfde4908969a Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 16 Jul 2018 13:17:07 -0400 Subject: malloc the deflate buffer in pngo The stack is a baby. --- bin/pngo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/pngo.c b/bin/pngo.c index 49c734da..d5f7b652 100644 --- a/bin/pngo.c +++ b/bin/pngo.c @@ -334,7 +334,9 @@ static void writeData(void) { if (verbose) fprintf(stderr, "%s: data size %zu\n", path, dataSize()); uLong size = compressBound(dataSize()); - uint8_t deflate[size]; + uint8_t *deflate = malloc(size); + if (!deflate) err(EX_OSERR, "malloc"); + int error = compress2(deflate, &size, data, dataSize(), Z_BEST_COMPRESSION); if (error != Z_OK) errx(EX_SOFTWARE, "%s: compress2: %d", path, error); @@ -343,6 +345,8 @@ static void writeData(void) { writeExpect(deflate, size); writeCrc(); + free(deflate); + if (verbose) fprintf(stderr, "%s: deflate size %lu\n", path, size); } -- cgit 1.4.1