aboutsummaryrefslogtreecommitdiff
path: root/src/backend_libpng.c
diff options
context:
space:
mode:
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;
}