diff --git a/dune/gfe/localgeodesicfeadolcstiffness.hh b/dune/gfe/localgeodesicfeadolcstiffness.hh
index 1947a741d8848445375fd71bd19b7338d776abeb..1dc7c18b89f8da164915b41deb3236772c309313 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