diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-05-08 17:36:39 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-05-08 17:36:39 +0200 |
| commit | 3c99b45f2c34d1bbdd752a51c1704e594f341c31 (patch) | |
| tree | 0998acb0f2812ffccea5448dbc1839f4568cba1e | |
| parent | f42288b1b66510ebe02dc1c742f8e0d38b624502 (diff) | |
| download | PROJ-3c99b45f2c34d1bbdd752a51c1704e594f341c31.tar.gz PROJ-3c99b45f2c34d1bbdd752a51c1704e594f341c31.zip | |
proj_normalize_for_visualization(): fix crash when ctx == nullptr
| -rw-r--r-- | src/iso19111/c_api.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 85421fa0..ceb27111 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -35,6 +35,7 @@ #include <cstdarg> #include <cstring> #include <map> +#include <memory> #include <new> #include <utility> #include <vector> @@ -6796,9 +6797,12 @@ int proj_cs_get_axis_info(PJ_CONTEXT *ctx, const PJ *cs, int index, */ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { + SANITIZE_CTX(ctx); if (!obj->alternativeCoordinateOperations.empty()) { try { - auto pjNew = pj_new(); + auto pjNew = std::unique_ptr<PJ>(pj_new()); + if (!pjNew) + return nullptr; pjNew->ctx = ctx; for (const auto &alt : obj->alternativeCoordinateOperations) { auto co = dynamic_cast<const CoordinateOperation *>( @@ -6838,7 +6842,7 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { co->nameStr()); } } - return pjNew; + return pjNew.release(); } catch (const std::exception &e) { proj_log_debug(ctx, __FUNCTION__, e.what()); return nullptr; |
