From 2fd9c50b14ced59e40e10138ebd65a1921768f9a Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Mon, 17 Oct 2016 22:05:23 +0200 Subject: [PATCH] Prevent memory leak in restoration of curvature matrix --- src/ctlike/ctlike.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ctlike/ctlike.cpp b/src/ctlike/ctlike.cpp index 8055bb3..8199bdc 100644 --- a/src/ctlike/ctlike.cpp +++ b/src/ctlike/ctlike.cpp @@ -228,12 +228,9 @@ void ctlike::run(void) // Optimize model parameters using LM optimizer optimize_lm(); - // Get pointer to curvature matrix - GMatrixSparse* curvature_ptr = - const_cast(m_obs.function()).curvature(); - // Store copy of curvature matrix - GMatrixSparse curvature = *curvature_ptr; + GMatrixSparse curvature = + *(const_cast(m_obs.function()).curvature()); // Store Npred double npred = m_obs.npred(); @@ -313,7 +310,8 @@ void ctlike::run(void) restore_edisp(m_obs, save_edisp); // Restore curvature matrix - *curvature_ptr = curvature; + *(const_cast(m_obs.function()).curvature()) = + curvature; // Return return; -- libgit2 0.21.4