summaryrefslogtreecommitdiff
path: root/ff2ppm.c
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2016-03-21 22:54:49 +0100
committerFRIGN <dev@frign.de>2016-03-21 22:54:49 +0100
commitfdf5a2b53a7499e5860323255d914191aee7cdba (patch)
tree7415e0d8fff9b9651cd48cd8b2c32a1f1d13d082 /ff2ppm.c
parentf0a4ce113d0e9dc50110a0ad9e98433d05aa2307 (diff)
Write a better format for the row-buffer allocation
Diffstat (limited to 'ff2ppm.c')
-rw-r--r--ff2ppm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ff2ppm.c b/ff2ppm.c
index 09eb346..265e317 100644
--- a/ff2ppm.c
+++ b/ff2ppm.c
@@ -74,17 +74,17 @@ main(int argc, char *argv[])
fprintf(stderr, "%s: invalid height: zero\n", argv0);
return 1;
}
+
if (width > SIZE_MAX / ((sizeof("RGBA") - 1) * sizeof(uint16_t))) {
fprintf(stderr, "%s: row length integer overflow\n", argv0);
return 1;
}
-
rowlen = width * (sizeof("RGBA") - 1);
if (!(row = malloc(rowlen * sizeof(uint16_t)))) {
fprintf(stderr, "%s: malloc: %s\n", argv0, strerror(errno));
return 1;
}
- if (!(rowout = malloc(width * sizeof("RGB") - 1))) {
+ if (!(rowout = malloc(width * (sizeof("RGB") - 1) * sizeof(uint16_t)))) {
fprintf(stderr, "%s: malloc: %s\n", argv0, strerror(errno));
return 1;
}