diff options
Diffstat (limited to 'editor/pnmscalefixed.c')
-rw-r--r-- | editor/pnmscalefixed.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c index 7d33a9c2..1a89a2e5 100644 --- a/editor/pnmscalefixed.c +++ b/editor/pnmscalefixed.c @@ -19,6 +19,7 @@ ** */ +#include <limits.h> #include <math.h> #include "pm_c_util.h" @@ -215,7 +216,7 @@ compute_output_dimensions(const struct cmdline_info cmdline, int * newrowsP, int * newcolsP) { if (cmdline.pixels) { - if (rows * cols <= cmdline.pixels) { + if (rows <= cmdline.pixels / cols) { *newrowsP = rows; *newcolsP = cols; } else { @@ -446,6 +447,10 @@ main(int argc, char **argv ) { unfilled. We can address that by stretching, whereas the other case would require throwing away some of the input. */ + if (newcols > INT_MAX / SCALE) + pm_error("New image width (%d) is uncomputably large", newcols); + if (newrows > INT_MAX / SCALE) + pm_error("New image height (%d) is uncomputably large", newrows); sxscale = SCALE * newcols / cols; syscale = SCALE * newrows / rows; |