Fix a leak in SchurComplementSolver.
cholmod_lhs was not being freed before
the SolveImpl function returned if the
underlying linear solver failed.
Change-Id: Id45db4f69a2821e43dc00fc975718584d426f44d
diff --git a/internal/ceres/schur_complement_solver.cc b/internal/ceres/schur_complement_solver.cc
index 2f407fd..d3eef5d 100644
--- a/internal/ceres/schur_complement_solver.cc
+++ b/internal/ceres/schur_complement_solver.cc
@@ -330,7 +330,10 @@
}
summary.termination_type =
- ss_.Cholesky(cholmod_lhs, factor_, &summary.message);
+ ss_.Cholesky(cholmod_lhs, factor_, &summary.message);
+
+ ss_.Free(cholmod_lhs);
+
if (summary.termination_type != LINEAR_SOLVER_SUCCESS) {
return summary;
}
@@ -340,7 +343,6 @@
cholmod_dense* cholmod_solution = ss_.Solve(factor_,
cholmod_rhs,
&summary.message);
- ss_.Free(cholmod_lhs);
ss_.Free(cholmod_rhs);
if (cholmod_solution == NULL) {