From f94f1ddeaa83bab4f6f3f9d5720a777e569c781b Mon Sep 17 00:00:00 2001 From: "backporting[bot]" <42222807+backporting[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2019 22:40:53 +0200 Subject: [Backport 6.2] Fix segfaults in case of out-of-memory situations (#1684) (fixes #1678) --- src/ell_set.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ell_set.cpp') 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 #include #include #include @@ -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; -- cgit v1.2.3