diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-05-20 22:06:46 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-05-22 11:56:15 +0200 |
| commit | 4730f1a8ddf849278f298842a08c7ff2d9b574bb (patch) | |
| tree | 5648e107b621802f84effde3526713065534fe27 | |
| parent | e1ed32922b718fa1a5b46a8fa6b5a42919e013a9 (diff) | |
| download | PROJ-4730f1a8ddf849278f298842a08c7ff2d9b574bb.tar.gz PROJ-4730f1a8ddf849278f298842a08c7ff2d9b574bb.zip | |
pj_init(): fix memory leak of pj->geod
Whe PIN = (*proj)(PIN) fails, it doesn't free the geod member.
So allocate it afterwards.
Credit to OSS Fuzz
| -rw-r--r-- | src/pj_init.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pj_init.c b/src/pj_init.c index 1f09b0f2..fefcb8fa 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -668,11 +668,6 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { else PIN->from_greenwich = 0.0; - /* Private object for the geodesic functions */ - PIN->geod = pj_calloc (1, sizeof (struct geod_geodesic)); - if (0!=PIN->geod) - geod_init(PIN->geod, PIN->a, (1 - sqrt (1 - PIN->es))); - /* projection specific initialization */ if (!(PIN = (*proj)(PIN)) || ctx->last_errno) { bum_call: /* cleanup error return */ @@ -685,6 +680,12 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { } PIN = 0; } + else { + /* Private object for the geodesic functions */ + PIN->geod = pj_calloc (1, sizeof (struct geod_geodesic)); + if (0!=PIN->geod) + geod_init(PIN->geod, PIN->a, (1 - sqrt (1 - PIN->es))); + } return PIN; } |
