From adeca911c16bc783963ee98d075a75b70d46b110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olli=20R=C3=A4is=C3=A4?= Date: Wed, 10 Jun 2020 12:52:14 +0300 Subject: Fix access violation in proj_context_get_database_metadata --- src/iso19111/c_api.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 340d9fb9..90c8a8cd 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -348,6 +348,10 @@ const char *proj_context_get_database_metadata(PJ_CONTEXT *ctx, // temporary variable must be used as getDBcontext() might create // ctx->cpp_context auto osVal(getDBcontext(ctx)->getMetadata(key)); + if (osVal == nullptr) { + ctx->cpp_context->autoCloseDbIfNeeded(); + return nullptr; + } ctx->cpp_context->lastDbMetadataItem_ = osVal; ctx->cpp_context->autoCloseDbIfNeeded(); return ctx->cpp_context->lastDbMetadataItem_.c_str(); -- cgit v1.2.3