diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-02-03 14:48:17 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-02-03 14:48:17 +0100 |
| commit | 24c1272cf4397614fb7ea5502bba9258e6a8f972 (patch) | |
| tree | d6d3579c439869fb0740dec37844e1cd34c84e56 /src/iso19111/common.cpp | |
| parent | b30ed5cba50688cea9ac2af90855177f84efea5a (diff) | |
| download | PROJ-24c1272cf4397614fb7ea5502bba9258e6a8f972.tar.gz PROJ-24c1272cf4397614fb7ea5502bba9258e6a8f972.zip | |
WKT1 export: avoid division by zero. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12854. Credit to OSS Fuzz
Diffstat (limited to 'src/iso19111/common.cpp')
| -rw-r--r-- | src/iso19111/common.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/iso19111/common.cpp b/src/iso19111/common.cpp index 57654d84..bdd836e1 100644 --- a/src/iso19111/common.cpp +++ b/src/iso19111/common.cpp @@ -172,21 +172,22 @@ void UnitOfMeasure::_exportToWKT( { const bool isWKT2 = formatter->version() == WKTFormatter::Version::WKT2; - if (formatter->forceUNITKeyword() && type() != Type::PARAMETRIC) { + const auto l_type = type(); + if (formatter->forceUNITKeyword() && l_type != Type::PARAMETRIC) { formatter->startNode(WKTConstants::UNIT, !codeSpace().empty()); } else if (!unitType.empty()) { formatter->startNode(unitType, !codeSpace().empty()); } else { - if (isWKT2 && type() == Type::LINEAR) { + if (isWKT2 && l_type == Type::LINEAR) { formatter->startNode(WKTConstants::LENGTHUNIT, !codeSpace().empty()); - } else if (isWKT2 && type() == Type::ANGULAR) { + } else if (isWKT2 && l_type == Type::ANGULAR) { formatter->startNode(WKTConstants::ANGLEUNIT, !codeSpace().empty()); - } else if (isWKT2 && type() == Type::SCALE) { + } else if (isWKT2 && l_type == Type::SCALE) { formatter->startNode(WKTConstants::SCALEUNIT, !codeSpace().empty()); - } else if (isWKT2 && type() == Type::TIME) { + } else if (isWKT2 && l_type == Type::TIME) { formatter->startNode(WKTConstants::TIMEUNIT, !codeSpace().empty()); - } else if (isWKT2 && type() == Type::PARAMETRIC) { + } else if (isWKT2 && l_type == Type::PARAMETRIC) { formatter->startNode(WKTConstants::PARAMETRICUNIT, !codeSpace().empty()); } else { @@ -211,7 +212,7 @@ void UnitOfMeasure::_exportToWKT( formatter->addQuotedString(l_name); } const auto &factor = conversionToSI(); - if (!isWKT2 || factor != 0.0) { + if (!isWKT2 || l_type != Type::TIME || factor != 0.0) { // Some TIMEUNIT do not have a conversion factor formatter->add(factor); } |
