From 46006f9d7c625b7492e7c7e56130ef7b7cd12751 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 3 Sep 2013 16:30:08 +0000
Subject: [PATCH] fix memory leak

[[Imported from SVN: r9422]]
---
 dune/gfe/localgeodesicfeadolcstiffness.hh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dune/gfe/localgeodesicfeadolcstiffness.hh b/dune/gfe/localgeodesicfeadolcstiffness.hh
index 1947a741..1dc7c18b 100644
--- a/dune/gfe/localgeodesicfeadolcstiffness.hh
+++ b/dune/gfe/localgeodesicfeadolcstiffness.hh
@@ -202,7 +202,7 @@ assembleHessian(const Entity& element,
     /////////////////////////////////////////////////////////////////
     // Compute Hessian
     /////////////////////////////////////////////////////////////////
-    double** rawHessian = (double**) malloc(nDoubles*sizeof(double*));
+    double* rawHessian[nDoubles];
     for(size_t i=0; i<nDoubles; i++)
         rawHessian[i] = (double*)malloc((i+1)*sizeof(double));
     hessian(1,nDoubles,xp.data(),rawHessian);
@@ -216,6 +216,9 @@ assembleHessian(const Entity& element,
       }
     }
 
+    for(size_t i=0; i<nDoubles; i++)
+        free(rawHessian[i]);
+
     // From this, compute the Hessian with respect to the manifold (which we assume here is embedded
     // isometrically in a Euclidean space.
     // For the detailed explanation of the following see: Absil, Mahoney, Trumpf, "An extrinsic look
-- 
GitLab