aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2017-06-13 16:50:44 +0200
committerGitHub <noreply@github.com>2017-06-13 16:50:44 +0200
commit4cf473f9ba1c90f8c2d2945d85ca6e42466ecf1a (patch)
tree61015aaf17f12eee4bb4eca77aabb4a91501f718 /src
parentc606094b8fa18a7c6da83b54b5e59f0eb470324c (diff)
parente1ad1046873056ab3bfc3262bd343e8c874f395c (diff)
downloadPROJ-4cf473f9ba1c90f8c2d2945d85ca6e42466ecf1a.tar.gz
PROJ-4cf473f9ba1c90f8c2d2945d85ca6e42466ecf1a.zip
Merge pull request #524 from rouault/fix_memleak_in_vgridshift
PJ_vgridshift.c: fix memleak in initialization if grid loading fail
Diffstat (limited to 'src')
-rw-r--r--src/PJ_vgridshift.c10
-rw-r--r--src/pj_gridlist.c1
2 files changed, 7 insertions, 4 deletions
diff --git a/src/PJ_vgridshift.c b/src/PJ_vgridshift.c
index c91db968..72d97517 100644
--- a/src/PJ_vgridshift.c
+++ b/src/PJ_vgridshift.c
@@ -29,8 +29,8 @@ static XYZ forward_3d(LPZ lpz, PJ *P) {
/* Only try the gridshift if at least one grid is loaded,
* otherwise just pass the coordinate through unchanged. */
pj_apply_vgridshift( P, "sgrids",
- &(P->vgridlist_geoid),
- &(P->vgridlist_geoid_count),
+ &(P->gridlist),
+ &(P->gridlist_count),
1, 1, 0,
&point.xyz.x, &point.xyz.y, &point.xyz.z );
}
@@ -47,8 +47,8 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) {
/* Only try the gridshift if at least one grid is loaded,
* otherwise just pass the coordinate through unchanged. */
pj_apply_vgridshift( P, "sgrids",
- &(P->vgridlist_geoid),
- &(P->vgridlist_geoid_count),
+ &(P->gridlist),
+ &(P->gridlist_count),
0, 1, 0,
&point.xyz.x, &point.xyz.y, &point.xyz.z );
}
@@ -84,6 +84,8 @@ PJ *PROJECTION(vgridshift) {
/* Was gridlist compiled properly? */
if ( pj_ctx_get_errno(P->ctx) ) {
pj_log_error(P, "vgridshift: could not find required grid(s).");
+ pj_dalloc(P->gridlist);
+ P->gridlist = NULL;
return freeup_msg(P, -38);
}
diff --git a/src/pj_gridlist.c b/src/pj_gridlist.c
index 39ed200d..4193526f 100644
--- a/src/pj_gridlist.c
+++ b/src/pj_gridlist.c
@@ -193,6 +193,7 @@ PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids,
if( end_char >= sizeof(name) )
{
+ pj_dalloc( gridlist );
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return NULL;