aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-10-16 16:54:31 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-10-16 16:54:31 +0200
commit33683634ee17a6718c2ff8d18bdc12b2a74eb3e1 (patch)
treec2f5d3e998eb7b7e01cf39bed198af460ddc473f
parented1ab5539a566aeecc29bc8fef99cbd0cb06af1c (diff)
downloadPROJ-33683634ee17a6718c2ff8d18bdc12b2a74eb3e1.tar.gz
PROJ-33683634ee17a6718c2ff8d18bdc12b2a74eb3e1.zip
createOperations(): avoid harmless floating-point division by zero if conversion factor of target unit is 0. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39969
-rw-r--r--src/iso19111/operation/coordinateoperationfactory.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/iso19111/operation/coordinateoperationfactory.cpp b/src/iso19111/operation/coordinateoperationfactory.cpp
index b59eeb91..e9bd3cfe 100644
--- a/src/iso19111/operation/coordinateoperationfactory.cpp
+++ b/src/iso19111/operation/coordinateoperationfactory.cpp
@@ -4347,6 +4347,9 @@ void CoordinateOperationFactory::Private::createOperationsBoundToGeog(
const bool heightDepthReversal =
((srcIsUp && dstIsDown) || (srcIsDown && dstIsUp));
+ if (convDst == 0)
+ throw InvalidOperation(
+ "Conversion factor of target unit is 0");
const double factor = convSrc / convDst;
auto conv = Conversion::createChangeVerticalUnit(
util::PropertyMap().set(
@@ -4460,6 +4463,8 @@ void CoordinateOperationFactory::Private::createOperationsVertToVert(
const bool heightDepthReversal =
((srcIsUp && dstIsDown) || (srcIsDown && dstIsUp));
+ if (convDst == 0)
+ throw InvalidOperation("Conversion factor of target unit is 0");
const double factor = convSrc / convDst;
if (!equivalentVDatum) {
auto name = buildTransfName(sourceCRS->nameStr(), targetCRS->nameStr());
@@ -4557,6 +4562,8 @@ void CoordinateOperationFactory::Private::createOperationsVertToGeogBallpark(
const bool heightDepthReversal =
((srcIsUp && dstIsDown) || (srcIsDown && dstIsUp));
+ if (convDst == 0)
+ throw InvalidOperation("Conversion factor of target unit is 0");
const double factor = convSrc / convDst;
const auto &sourceCRSExtent = getExtent(sourceCRS);