fix memory leak of pj_ctx if a projection cannot be initialized
This commit is contained in:
parent
bfb0f22788
commit
7cca1489b7
1 changed files with 9 additions and 4 deletions
|
@ -135,10 +135,15 @@ void projection::init()
|
|||
#if PJ_VERSION >= 480
|
||||
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
|
||||
if (!proj_) throw proj_init_error(params_);
|
||||
#endif
|
||||
is_geographic_ = pj_is_latlong(proj_) ? true : false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue