fix memory leak of pj_ctx if a projection cannot be initialized

This commit is contained in:
Dane Springmeyer 2012-04-11 08:06:29 -07:00
parent 56d8f7a3f9
commit 0370913bfc

View file

@ -135,12 +135,17 @@ void projection::init()
mutex::scoped_lock lock(mutex_);
#endif
#if PJ_VERSION >= 480
proj_ctx_=pj_ctx_alloc();
proj_=pj_init_plus_ctx(proj_ctx_, params_.c_str());
proj_ctx_ = pj_ctx_alloc();
proj_ = pj_init_plus_ctx(proj_ctx_, params_.c_str());
if (!proj_)
{
if (proj_ctx_) pj_ctx_free(proj_ctx_);
throw proj_init_error(params_);
}
#else
proj_=pj_init_plus(params_.c_str());
#endif
proj_ = pj_init_plus(params_.c_str());
if (!proj_) throw proj_init_error(params_);
#endif
is_geographic_ = pj_is_latlong(proj_) ? true : false;
}