diff options
author | June McEnroe <june@causal.agency> | 2018-07-16 13:17:07 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-07-16 13:17:07 -0400 |
commit | 381572e41c52eb3ac9419858d102bec5fc648dc5 (patch) | |
tree | c976c92ceb6f15c66e561e8d8098bc88a4aad3c9 /bin | |
parent | Add shed blood (diff) | |
download | src-381572e41c52eb3ac9419858d102bec5fc648dc5.tar.gz src-381572e41c52eb3ac9419858d102bec5fc648dc5.zip |
malloc the deflate buffer in pngo
The stack is a baby.
Diffstat (limited to '')
-rw-r--r-- | bin/pngo.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/pngo.c b/bin/pngo.c index f8359d3a..76898b68 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); } |