diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/pamdice.c | 18 | ||||
-rw-r--r-- | editor/pnmshear.c | 8 |
2 files changed, 17 insertions, 9 deletions
diff --git a/editor/pamdice.c b/editor/pamdice.c index f4b05a8d..32881129 100644 --- a/editor/pamdice.c +++ b/editor/pamdice.c @@ -84,7 +84,9 @@ parseCommandLine(int argc, char ** argv, /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (cmdlineP->sliceVertically) { - if (hoverlapSpec) { + if (cmdlineP->width < 1) + pm_error("-width value must not be zero"); + else if (hoverlapSpec) { if (cmdlineP->hoverlap > cmdlineP->width - 1) pm_error("-hoverlap value must be less than -width (%u). " "You specified %u.", @@ -93,7 +95,9 @@ parseCommandLine(int argc, char ** argv, cmdlineP->hoverlap = 0; } if (cmdlineP->sliceHorizontally) { - if (voverlapSpec) { + if (cmdlineP->height < 1) + pm_error("-height value must not be zero"); + else if (voverlapSpec) { if (cmdlineP->voverlap > cmdlineP->height - 1) pm_error("-voverlap value must be less than -height (%u). " "You specified %u.", @@ -209,7 +213,6 @@ ndigits(unsigned int const arg) { static void computeOutputFilenameFormat(int const format, - char const outstem[], unsigned int const nHorizSlice, unsigned int const nVertSlice, const char ** const filenameFormatP) { @@ -224,9 +227,8 @@ computeOutputFilenameFormat(int const format, default: filenameSuffix = ""; break; } - pm_asprintf(filenameFormatP, "%s_%%0%uu_%%0%uu.%s", - outstem, ndigits(nHorizSlice), ndigits(nVertSlice), - filenameSuffix); + pm_asprintf(filenameFormatP, "%%s_%%0%uu_%%0%uu.%s", + ndigits(nHorizSlice), ndigits(nVertSlice), filenameSuffix); if (*filenameFormatP == NULL) pm_error("Unable to allocate memory for filename format string"); @@ -253,13 +255,13 @@ openOutStreams(struct pam const inpam, const char * filenameFormat; unsigned int vertSlice; - computeOutputFilenameFormat(inpam.format, outstem, nHorizSlice, nVertSlice, + computeOutputFilenameFormat(inpam.format, nHorizSlice, nVertSlice, &filenameFormat); for (vertSlice = 0; vertSlice < nVertSlice; ++vertSlice) { const char * filename; - pm_asprintf(&filename, filenameFormat, horizSlice, vertSlice); + pm_asprintf(&filename, filenameFormat, outstem, horizSlice, vertSlice); if (filename == NULL) pm_error("Unable to allocate memory for output filename"); diff --git a/editor/pnmshear.c b/editor/pnmshear.c index 1c330bb7..c705c261 100644 --- a/editor/pnmshear.c +++ b/editor/pnmshear.c @@ -217,6 +217,7 @@ main(int argc, const char * argv[]) { int row; xelval maxval, newmaxval; double shearfac; + double newcolsD; struct CmdlineInfo cmdline; @@ -242,7 +243,12 @@ main(int argc, const char * argv[]) { shearfac = fabs(tan(cmdline.angle)); - newcols = rows * shearfac + cols + 0.999999; + newcolsD = (double) rows * shearfac + cols + 0.999999; + if (newcolsD > INT_MAX-2) + pm_error("angle is too close to +/-90 degrees; " + "output image too wide for computation"); + else + newcols = (int) newcolsD; pnm_writepnminit(stdout, newcols, rows, newmaxval, newformat, 0); newxelrow = pnm_allocrow(newcols); |