diff options
-rw-r--r-- | converter/other/pamtosvg/fit.c | 42 | ||||
-rw-r--r-- | converter/pbm/pbmtoxbm.c | 4 | ||||
-rw-r--r-- | doc/HISTORY | 6 | ||||
-rw-r--r-- | lib/libpbm2.c | 2 | ||||
-rw-r--r-- | version.mk | 2 |
5 files changed, 45 insertions, 11 deletions
diff --git a/converter/other/pamtosvg/fit.c b/converter/other/pamtosvg/fit.c index 179b3bdf..06e708c2 100644 --- a/converter/other/pamtosvg/fit.c +++ b/converter/other/pamtosvg/fit.c @@ -1379,14 +1379,26 @@ findHalfTangentBeg(curve * const curveP, unsigned int const thisIndex = p + 1; float_coord const thisPoint = CURVE_POINT(curveP, thisIndex); - /* Perhaps we should weight the tangent from `thisPoint' by some - factor dependent on the distance from the tangent point. - */ - sum = Vadd(sum, Pdirection(thisPoint, tangentPoint)); - ++n; + if (epsilon_equal(thisPoint.x, tangentPoint.x) && + epsilon_equal(thisPoint.y, tangentPoint.y) && + epsilon_equal(thisPoint.z, tangentPoint.z)) { + /* It's the same point; can't compute a slope */ + } else { + /* Perhaps we should weight the tangent from `thisPoint' by some + factor dependent on the distance from the tangent point. + */ + sum = Vadd(sum, Pdirection(thisPoint, tangentPoint)); + ++n; + } } - mean = Vmult_scalar(sum, 1.0 / n); + if (n >= 1) + mean = Vmult_scalar(sum, 1.0 / n); + else { + mean.dx = 1.0; + mean.dy = 0.0; + mean.dz = 0.0; + } return mean; } @@ -1418,11 +1430,23 @@ findHalfTangentEnd(curve * const curveP, unsigned int const thisIndex = CURVE_LENGTH(curveP) - 1 - p; float_coord const thisPoint = CURVE_POINT(curveP, thisIndex); - sum = Vadd(sum, Pdirection(tangentPoint, thisPoint)); - ++n; + if (epsilon_equal(thisPoint.x, tangentPoint.x) && + epsilon_equal(thisPoint.y, tangentPoint.y) && + epsilon_equal(thisPoint.z, tangentPoint.z)) { + /* It's the same point; can't compute a slope */ + } else { + sum = Vadd(sum, Pdirection(tangentPoint, thisPoint)); + ++n; + } } - mean = Vmult_scalar(sum, 1.0 / n); + if (n >= 1) + mean = Vmult_scalar(sum, 1.0 / n); + else { + mean.dx = 1.0; + mean.dy = 0.0; + mean.dz = 0.0; + } return mean; } diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c index ecb72b30..1a003189 100644 --- a/converter/pbm/pbmtoxbm.c +++ b/converter/pbm/pbmtoxbm.c @@ -353,6 +353,10 @@ convertRaster(FILE * const ifP, unsigned char * bitrow; unsigned int row; + if (cols > UINT_MAX - bitsPerUnit) + pm_error("Image is too wide (%u columns) for computations", + cols); + putinit(xbmVersion); bitrow = pbm_allocrow_packed(cols + padright); diff --git a/doc/HISTORY b/doc/HISTORY index 288aded6..775da357 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,12 @@ Netpbm. CHANGE HISTORY -------------- +23.09.24 BJH Release 11.02.04 + + pamtosvg: fix hang. + + pbmtoxbm: Fix spurious output with really wide rows. + 23.09.02 BJH Release 11.02.03 pamaddnoise: fix very incorrect noise added for all types. diff --git a/lib/libpbm2.c b/lib/libpbm2.c index 2a2e2aac..244d5835 100644 --- a/lib/libpbm2.c +++ b/lib/libpbm2.c @@ -53,7 +53,7 @@ pbm_readpbminitrest( FILE * const file, if (*colsP < 0) pm_error("Number of columns in header is too large."); if (*rowsP < 0) - pm_error("Number of columns in header is too large."); + pm_error("Number of rows in header is too large."); } diff --git a/version.mk b/version.mk index 9218c3f4..e532f921 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 11 NETPBM_MINOR_RELEASE = 2 -NETPBM_POINT_RELEASE = 3 +NETPBM_POINT_RELEASE = 4 |