aboutsummaryrefslogtreecommitdiff
path: root/src/pj_gridlist.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/pj_gridlist.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/pj_gridlist.c')
-rw-r--r--src/pj_gridlist.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pj_gridlist.c b/src/pj_gridlist.c
index 1123274e..4617591c 100644
--- a/src/pj_gridlist.c
+++ b/src/pj_gridlist.c
@@ -28,6 +28,7 @@
#define PJ_LIB__
+#include <errno.h>
#include <projects.h>
#include <string.h>
#include <math.h>
@@ -103,6 +104,10 @@ static int pj_gridlist_merge_gridfile( projCtx ctx,
int new_max = *p_gridmax + 20;
new_list = (PJ_GRIDINFO **) pj_calloc(new_max, sizeof(void *));
+ if (!new_list) {
+ pj_ctx_set_errno( ctx, ENOMEM );
+ return 0;
+ }
if( *p_gridlist != NULL )
{
memcpy( new_list, *p_gridlist,
@@ -132,8 +137,6 @@ static int pj_gridlist_merge_gridfile( projCtx ctx,
if( this_grid == NULL )
{
- /* we should get at least a stub grid with a missing "ct" member */
- assert( FALSE );
return 0;
}