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:37:11 +0200 |
| commit | 5bc094eccbb4fd8ed01b160997ca6be8e9a3d01f (patch) | |
| tree | 0998acb0f2812ffccea5448dbc1839f4568cba1e /src | |
| parent | 9efc86ad44e8a810b3dd5f66efcbc2d8d77e55ef (diff) | |
| download | PROJ-5bc094eccbb4fd8ed01b160997ca6be8e9a3d01f.tar.gz PROJ-5bc094eccbb4fd8ed01b160997ca6be8e9a3d01f.zip | |
proj_normalize_for_visualization(): fix crash when ctx == nullptr
Diffstat (limited to 'src')
| -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; |
