aboutsummaryrefslogtreecommitdiff
path: root/src/pj_init.c
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-05-30 12:14:26 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-05-30 12:14:26 +0200
commita395e6e244e04dd09284e24eb1ca3ff2a7c9f37f (patch)
treeba43adeeac721f4b86f2b1842ee74a534a9a00ab /src/pj_init.c
parent6bb6184a84f136f1686d51d43bfc04065e329ae5 (diff)
downloadPROJ-a395e6e244e04dd09284e24eb1ca3ff2a7c9f37f.tar.gz
PROJ-a395e6e244e04dd09284e24eb1ca3ff2a7c9f37f.zip
catalog: memory leak and crashes related fixes
* pj_transform() crashes on a catalog that has no matching grid * pj_free() and pj_gc_unloadall() badly interact. No longer try to free the catalog object in pj_free(). That is the job of pj_gc_unloadall() * Fix memory leaks in pj_gc_readcatalog() and pj_gc_unloadall() Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1923 Credit to OSS Fuzz.
Diffstat (limited to 'src/pj_init.c')
-rw-r--r--src/pj_init.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pj_init.c b/src/pj_init.c
index 764784f5..e3d99a8f 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -735,8 +735,11 @@ pj_free(PJ *P) {
if( P->catalog_name != NULL )
pj_dalloc( P->catalog_name );
- if( P->catalog != NULL )
- pj_dalloc( P->catalog );
+ /* We used to call pj_dalloc( P->catalog ), but this will leak */
+ /* memory. The safe way to clear catalog and grid is to call */
+ /* pj_gc_unloadall(pj_get_default_ctx()); and pj_deallocate_grids(); */
+ /* TODO: we should probably have a public pj_cleanup() method to do all */
+ /* that */
if( P->geod != NULL )
pj_dalloc( P->geod );