diff options
Diffstat (limited to 'converter/ppm/ppmtolj.c')
-rw-r--r-- | converter/ppm/ppmtolj.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/converter/ppm/ppmtolj.c b/converter/ppm/ppmtolj.c index 8acdfe5e..e2e03ac5 100644 --- a/converter/ppm/ppmtolj.c +++ b/converter/ppm/ppmtolj.c @@ -11,6 +11,7 @@ */ #include <stdbool.h> +#include <limits.h> #include <string.h> #include "ppm.h" @@ -206,6 +207,11 @@ printRaster(FILE * const ifP, pixelrow = ppm_allocrow(cols); + if (cols > UINT_MAX/6) { + /* We may need a row buffer of up to cols * 6 bytes for compression */ + pm_error("Image is uncomputably wide (%u columns)", cols); + } + obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char)); cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char)); |