aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryonarw <yonarw@gmail.com>2019-10-18 22:34:29 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-10-18 22:34:29 +0200
commit00666ee8352ea188f89c53bc38823ab711dacde5 (patch)
tree154a6c994797b98ca47085fa78699d902430e678 /src
parentf9ba18a4d03e6219f0da0511a5f3e8eadf1851b4 (diff)
downloadPROJ-00666ee8352ea188f89c53bc38823ab711dacde5.tar.gz
PROJ-00666ee8352ea188f89c53bc38823ab711dacde5.zip
Fix segfaults in case of out-of-memory situations (fixes #1678) (#1679)
Diffstat (limited to 'src')
-rw-r--r--src/datum_set.cpp12
-rw-r--r--src/ell_set.cpp8
2 files changed, 20 insertions, 0 deletions
diff --git a/src/datum_set.cpp b/src/datum_set.cpp
index c1cb4cb9..873d7be5 100644
--- a/src/datum_set.cpp
+++ b/src/datum_set.cpp
@@ -85,10 +85,22 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef)
entry[ sizeof(entry) - 1 ] = '\0';
curr = curr->next = pj_mkparam(entry);
+ if (nullptr == curr)
+ {
+ pj_ctx_set_errno(ctx, ENOMEM);
+ return 1;
+ }
}
if( pj_datums[i].defn && strlen(pj_datums[i].defn) > 0 )
+ {
curr = curr->next = pj_mkparam(pj_datums[i].defn);
+ if (nullptr == curr)
+ {
+ pj_ctx_set_errno(ctx, ENOMEM);
+ return 1;
+ }
+ }
(void)curr; /* make clang static analyzer happy */
}
diff --git a/src/ell_set.cpp b/src/ell_set.cpp
index d2930ca4..bb46b3a4 100644
--- a/src/ell_set.cpp
+++ b/src/ell_set.cpp
@@ -1,5 +1,6 @@
/* set ellipsoid parameters a and es */
+#include <errno.h>
#include <math.h>
#include <stddef.h>
#include <string.h>
@@ -156,7 +157,14 @@ static int ellps_ellps (PJ *P) {
err = proj_errno_reset (P);
paralist* new_params = pj_mkparam (ellps->major);
+ if (nullptr == new_params)
+ return proj_errno_set (P, ENOMEM);
new_params->next = pj_mkparam (ellps->ell);
+ if (nullptr == new_params->next)
+ {
+ pj_dealloc(new_params);
+ return proj_errno_set (P, ENOMEM);
+ }
paralist* old_params = P->params;
P->params = new_params;