From 5b608987fd2971b0628973301dd52c0fc46d1a09 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Fri, 7 Nov 2014 17:55:30 -0500 Subject: [PATCH] Fix a memory leak in SatSolverRegistry (re: bug #594). --- src/prop/sat_solver_factory.cpp | 4 ++-- src/prop/sat_solver_factory.h | 9 +++------ src/prop/sat_solver_registry.cpp | 3 ++- src/prop/sat_solver_registry.h | 5 ++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/prop/sat_solver_factory.cpp b/src/prop/sat_solver_factory.cpp index 650c05dd4..3d3e76205 100644 --- a/src/prop/sat_solver_factory.cpp +++ b/src/prop/sat_solver_factory.cpp @@ -46,5 +46,5 @@ void SatSolverFactory::getSolverIds(std::vector& solvers) { SatSolverRegistry::getSolverIds(solvers); } -} /* namespace CVC4::prop */ -} /* namespace CVC4 */ +} /* CVC4::prop namespace */ +} /* CVC4 namespace */ diff --git a/src/prop/sat_solver_factory.h b/src/prop/sat_solver_factory.h index 0b419d545..009622212 100644 --- a/src/prop/sat_solver_factory.h +++ b/src/prop/sat_solver_factory.h @@ -36,10 +36,7 @@ public: /** Get the solver ids that are available */ static void getSolverIds(std::vector& solvers); -}; - -} -} - - +};/* class SatSolverFactory */ +}/* CVC4::prop namespace */ +}/* CVC4 namespace */ diff --git a/src/prop/sat_solver_registry.cpp b/src/prop/sat_solver_registry.cpp index 7867c6cc3..5cf79699f 100644 --- a/src/prop/sat_solver_registry.cpp +++ b/src/prop/sat_solver_registry.cpp @@ -52,8 +52,9 @@ SatSolverRegistry* SatSolverRegistry::getInstance() { SatSolverRegistry::~SatSolverRegistry() { registry_type::const_iterator it = d_solvers.begin(); - registry_type::const_iterator it_end = d_solvers.begin(); + registry_type::const_iterator it_end = d_solvers.end(); for (; it != it_end; ++ it) { delete it->second; } + d_solvers.clear(); } diff --git a/src/prop/sat_solver_registry.h b/src/prop/sat_solver_registry.h index b8173866f..7a326d6c8 100644 --- a/src/prop/sat_solver_registry.h +++ b/src/prop/sat_solver_registry.h @@ -111,6 +111,5 @@ public: template const size_t SatSolverConstructor::s_solverId = SatSolverRegistry::getInstance()->registerSolver(typeid(Solver).name()); -} -} - +}/* CVC4::prop namespace */ +}/* CVC4 namespace */ -- 2.30.2