From 533585fda6706960fd45772c7d47501c12af804a Mon Sep 17 00:00:00 2001 From: dehnert Date: Mon, 20 Nov 2017 13:16:23 +0100 Subject: [PATCH] moving to weak_pointers in variables to resolve memory leak in expression manager --- src/storm/storage/expressions/Variable.cpp | 5 ++--- src/storm/storage/expressions/Variable.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/storm/storage/expressions/Variable.cpp b/src/storm/storage/expressions/Variable.cpp index 0259ab3e5..675f1caef 100644 --- a/src/storm/storage/expressions/Variable.cpp +++ b/src/storm/storage/expressions/Variable.cpp @@ -16,7 +16,7 @@ namespace storm { } bool Variable::operator==(Variable const& other) const { - return manager == other.manager && index == other.index; + return &this->getManager() == &other.getManager() && index == other.index; } bool Variable::operator!=(Variable const& other) const { @@ -48,8 +48,7 @@ namespace storm { } ExpressionManager const& Variable::getManager() const { - STORM_LOG_ASSERT(manager != nullptr, "Manager is null."); - return *manager; + return *manager.lock(); } bool Variable::hasBooleanType() const { diff --git a/src/storm/storage/expressions/Variable.h b/src/storm/storage/expressions/Variable.h index 8a51df376..3ecea02c0 100644 --- a/src/storm/storage/expressions/Variable.h +++ b/src/storm/storage/expressions/Variable.h @@ -138,7 +138,7 @@ namespace storm { private: // The manager that is responsible for this variable. - std::shared_ptr manager; + std::weak_ptr manager; // The index of the variable. uint_fast64_t index;