aboutsummaryrefslogtreecommitdiff
path: root/src/ell_set.cpp
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/ell_set.cpp
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/ell_set.cpp')
-rw-r--r--src/ell_set.cpp8
1 files changed, 8 insertions, 0 deletions
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;