aboutsummaryrefslogtreecommitdiff
path: root/src/backend_libpng.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-02-15 22:02:57 +0000
committerHarry Jeffery <harry@exec64.co.uk>2019-02-15 22:02:57 +0000
commite6b9072be34921353062661f7f0675deb3e229b7 (patch)
treef369707bd1052c023b874070d6382b7dfad02c22 /src/backend_libpng.c
parentd737b3443098fca64dddd0ca54c81e968c568b59 (diff)
downloadimv-e6b9072be34921353062661f7f0675deb3e229b7.tar.gz
png: Don't use non-portable alloca
Diffstat (limited to 'src/backend_libpng.c')
-rw-r--r--src/backend_libpng.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend_libpng.c b/src/backend_libpng.c
index 2696007..a4697c6 100644
--- a/src/backend_libpng.c
+++ b/src/backend_libpng.c
@@ -1,7 +1,6 @@
#include "backend_libpng.h"
#include "backend.h"
#include "source.h"
-#include <alloca.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -98,7 +97,7 @@ static int load_image(struct imv_source *src)
return -1;
}
- png_bytep *rows = alloca(sizeof(png_bytep) * src->height);
+ png_bytep *rows = malloc(sizeof(png_bytep) * src->height);
size_t row_len = png_get_rowbytes(private->png, private->info);
rows[0] = malloc(src->height * row_len);
for (int y = 1; y < src->height; ++y) {
@@ -107,14 +106,17 @@ static int load_image(struct imv_source *src)
if (setjmp(png_jmpbuf(private->png))) {
free(rows[0]);
+ free(rows);
report_error(src);
return -1;
}
png_read_image(private->png, rows);
+ void *bmp = rows[0];
+ free(rows);
fclose(private->file);
private->file = NULL;
- send_bitmap(src, rows[0]);
+ send_bitmap(src, bmp);
return 0;
}