[hackers] [farbfeld] Write a better format for the row-buffer allocation || FRIGN
commit fdf5a2b53a7499e5860323255d914191aee7cdba
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Mar 21 22:54:49 2016 +0100
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Mon Mar 21 22:54:49 2016 +0100
Write a better format for the row-buffer allocation
diff --git a/ff2ppm.c b/ff2ppm.c
index 09eb346..265e317 100644
--- a/ff2ppm.c
+++ b/ff2ppm.c
_AT_@ -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;
}
Received on Mon Mar 21 2016 - 22:55:06 CET
This archive was generated by hypermail 2.3.0
: Mon Mar 21 2016 - 23:00:15 CET