aboutsummaryrefslogtreecommitdiff
path: root/src/nad_init.c
diff options
context:
space:
mode:
authorAaron Puchert <aaronpuchert@alice-dsl.net>2017-10-20 14:35:35 +0200
committerThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-10-20 14:35:35 +0200
commit080e1a5ab59e36c316c3590b74feb07638276a99 (patch)
treeee53d5f1b3605aa1125aff23439894667adbf37c /src/nad_init.c
parent81bf085dce5ce6eac59835cd45dba6aecdb1a8e6 (diff)
downloadPROJ-080e1a5ab59e36c316c3590b74feb07638276a99.tar.gz
PROJ-080e1a5ab59e36c316c3590b74feb07638276a99.zip
Handle allocation failure when loading grid files (#616)
* Handle allocation failure when loading grid files Continuing #606, we tackle the same issues in the loading and processing of grid files. This should fix potential crashes and memory leaks, and makes sure the global lock is always released. * Use pj_calloc when zero-initialized memory is wanted
Diffstat (limited to 'src/nad_init.c')
-rw-r--r--src/nad_init.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nad_init.c b/src/nad_init.c
index 0a28e200..a9082f8f 100644
--- a/src/nad_init.c
+++ b/src/nad_init.c
@@ -224,7 +224,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid )
ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE));
if( ct == NULL )
{
- pj_ctx_set_errno( ctx, -38 );
+ pj_ctx_set_errno( ctx, ENOMEM );
return NULL;
}
@@ -241,6 +241,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid )
|| ct->lim.phi < 1 || ct->lim.phi > 100000 )
{
pj_ctx_set_errno( ctx, -38 );
+ pj_dalloc( ct );
return NULL;
}