diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-02-22 17:15:24 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2022-02-22 17:15:24 +0100 |
| commit | 643f2851984df00dd47278cecaecefec8c5a87bf (patch) | |
| tree | 1018ca130133886d1c4f02592fc40e67099ad2c4 | |
| parent | bd830a6f3faae20f9a1b9ca00b045101380a9504 (diff) | |
| download | PROJ-643f2851984df00dd47278cecaecefec8c5a87bf.tar.gz PROJ-643f2851984df00dd47278cecaecefec8c5a87bf.zip | |
ProjectedCRS::_exportToWKT(): avoid false positive warning about nullptr deref (CID 383356)
| -rw-r--r-- | src/iso19111/crs.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index 4750896a..881aec0b 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -4059,50 +4059,50 @@ void ProjectedCRS::_exportToWKT(io::WKTFormatter *formatter) const { if (found) l_esri_name = l_name; } - } - if (!isWKT2 && formatter->useESRIDialect() && !l_identifiers.empty() && - *(l_identifiers[0]->codeSpace()) == "ESRI" && dbContext) { - try { - const auto definition = dbContext->getTextDefinition( - "projected_crs", "ESRI", l_identifiers[0]->code()); - if (starts_with(definition, "PROJCS")) { - auto crsFromFromDef = io::WKTParser() - .attachDatabaseContext(dbContext) - .createFromWKT(definition); - if (_isEquivalentTo( - dynamic_cast<IComparable *>(crsFromFromDef.get()), - util::IComparable::Criterion::EQUIVALENT)) { - formatter->ingestWKTNode( - io::WKTNode::createFrom(definition)); - return; - } - } - } catch (const std::exception &) { - } - } else if (!isWKT2 && formatter->useESRIDialect() && !l_esri_name.empty()) { - try { - auto res = - io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI") - ->createObjectsFromName( - l_esri_name, - {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, - false); - if (res.size() == 1) { + if (!isWKT2 && !l_identifiers.empty() && + *(l_identifiers[0]->codeSpace()) == "ESRI") { + try { const auto definition = dbContext->getTextDefinition( - "projected_crs", "ESRI", - res.front()->identifiers()[0]->code()); + "projected_crs", "ESRI", l_identifiers[0]->code()); if (starts_with(definition, "PROJCS")) { + auto crsFromFromDef = io::WKTParser() + .attachDatabaseContext(dbContext) + .createFromWKT(definition); if (_isEquivalentTo( - dynamic_cast<IComparable *>(res.front().get()), + dynamic_cast<IComparable *>(crsFromFromDef.get()), util::IComparable::Criterion::EQUIVALENT)) { formatter->ingestWKTNode( io::WKTNode::createFrom(definition)); return; } } + } catch (const std::exception &) { + } + } else if (!isWKT2 && !l_esri_name.empty()) { + try { + auto res = + io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI") + ->createObjectsFromName( + l_esri_name, + {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, + false); + if (res.size() == 1) { + const auto definition = dbContext->getTextDefinition( + "projected_crs", "ESRI", + res.front()->identifiers()[0]->code()); + if (starts_with(definition, "PROJCS")) { + if (_isEquivalentTo( + dynamic_cast<IComparable *>(res.front().get()), + util::IComparable::Criterion::EQUIVALENT)) { + formatter->ingestWKTNode( + io::WKTNode::createFrom(definition)); + return; + } + } + } + } catch (const std::exception &) { } - } catch (const std::exception &) { } } |
