From 2c3867044308b592c75592cc0e837fe26b29a740 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Thu, 6 Mar 2014 10:25:57 +0100 Subject: [PATCH] prevent double-free in mapnik::projection A double-free can happen when init_proj4 is called outside of the constructor (for projections with defer_proj_init=true) and when that call fails. In this case proj_ctx_ is not set to NULL and then freed again in the destructor. Set to null to avoid second pj_ctx_free call. See #2170 --- src/projection.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/projection.cpp b/src/projection.cpp index e194f49da..08251a7f5 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -108,7 +108,10 @@ void projection::init_proj4() const proj_ = pj_init_plus_ctx(proj_ctx_, params_.c_str()); if (!proj_) { - if (proj_ctx_) pj_ctx_free(proj_ctx_); + if (proj_ctx_) { + pj_ctx_free(proj_ctx_); + proj_ctx_ = 0; + } throw proj_init_error(params_); } #else