diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-03-06 23:36:38 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-03-07 00:20:21 +0100 |
| commit | ec67ee73d1274150c1034477d77c36a451b55823 (patch) | |
| tree | 7c905c260a03a5f8329748cfc866b078bcd7d8bd /src/initcache.cpp | |
| parent | ecd5a542c1eb760a8570d45b01d395e658d22a88 (diff) | |
| download | PROJ-ec67ee73d1274150c1034477d77c36a451b55823.tar.gz PROJ-ec67ee73d1274150c1034477d77c36a451b55823.zip | |
initcache.cpp: add assertions for potential failed mem alloc (CID 314809, 314812)
Diffstat (limited to 'src/initcache.cpp')
| -rw-r--r-- | src/initcache.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/initcache.cpp b/src/initcache.cpp index cf9460ab..41605cc6 100644 --- a/src/initcache.cpp +++ b/src/initcache.cpp @@ -25,6 +25,7 @@ * DEALINGS IN THE SOFTWARE. *****************************************************************************/ +#include <assert.h> #include <string.h> #include "proj.h" @@ -49,6 +50,7 @@ paralist *pj_clone_paralist( const paralist *list) { paralist *newitem = (paralist *) malloc(sizeof(paralist) + strlen(list->param)); + assert(newitem); newitem->used = 0; newitem->next = nullptr; @@ -152,6 +154,7 @@ void pj_insert_initcache( const char *filekey, const paralist *list ) cache_alloc = cache_alloc * 2 + 15; cache_key_new = (char **) malloc(sizeof(char*) * cache_alloc); + assert(cache_key_new); if( cache_key && cache_count ) { memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count); @@ -161,6 +164,7 @@ void pj_insert_initcache( const char *filekey, const paralist *list ) cache_paralist_new = (paralist **) malloc(sizeof(paralist*) * cache_alloc); + assert(cache_paralist_new); if( cache_paralist && cache_count ) { memcpy( cache_paralist_new, cache_paralist, @@ -174,6 +178,7 @@ void pj_insert_initcache( const char *filekey, const paralist *list ) ** Duplicate the filekey and paralist, and insert in cache. */ cache_key[cache_count] = (char *) malloc(strlen(filekey)+1); + assert(cache_key[cache_count]); strcpy( cache_key[cache_count], filekey ); cache_paralist[cache_count] = pj_clone_paralist( list ); |
