aboutsummaryrefslogtreecommitdiff
path: root/src/4D_api.cpp
diff options
context:
space:
mode:
authorAaron Puchert <aaron.puchert@sap.com>2019-01-17 21:56:51 +0100
committerAaron Puchert <aaron.puchert@sap.com>2019-01-17 21:56:51 +0100
commitd6403c450a00a036787c9dbca73c1db2faaad9c0 (patch)
tree180b3e779cb104497f137918a97e7ec0e8739bef /src/4D_api.cpp
parent3fc48e6146e020b86a0ef87749cc645f9b4fa113 (diff)
downloadPROJ-d6403c450a00a036787c9dbca73c1db2faaad9c0.tar.gz
PROJ-d6403c450a00a036787c9dbca73c1db2faaad9c0.zip
Handle allocation failure in pj_trim_argv
The function can return nullptr, if calloc fails. If we then use that nullptr in pj_init_ctx_with_allow_init_epsg, we get a crash.
Diffstat (limited to 'src/4D_api.cpp')
-rw-r--r--src/4D_api.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index ba292262..013a4628 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -602,6 +602,11 @@ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) {
}
argv = pj_trim_argv (argc, args);
+ if (!argv) {
+ pj_dealloc(args);
+ proj_context_errno_set(ctx, ENOMEM);
+ return nullptr;
+ }
/* ...and let pj_init_ctx do the hard work */
/* New interface: forbid init=epsg:XXXX syntax by default */