From 0e2eea314b87b21646ab60e4b7d35bc48fcffbf7 Mon Sep 17 00:00:00 2001 From: Bernd Flemisch <bernd@iws.uni-stuttgart.de> Date: Thu, 10 Jan 2013 16:59:56 +0000 Subject: [PATCH] ImplicitProblem and MPNCModel: (more) properly initialize pointers and destroy result writers. Thanks to Philipp for triggering the issue. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@9964 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/implicit/common/implicitproblem.hh | 6 +++--- dumux/implicit/mpnc/mpncmodel.hh | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dumux/implicit/common/implicitproblem.hh b/dumux/implicit/common/implicitproblem.hh index 60fbfad75b..97979e658c 100644 --- a/dumux/implicit/common/implicitproblem.hh +++ b/dumux/implicit/common/implicitproblem.hh @@ -99,6 +99,7 @@ public: , timeManager_(&timeManager) , newtonMethod_(asImp_()) , newtonCtl_(asImp_()) + , resultWriter_(0) { // calculate the bounding box of the local partition of the grid view VertexIterator vIt = gridView.template begin<dim>(); @@ -119,13 +120,12 @@ public: // set a default name for the problem simName_ = "sim"; - - resultWriter_ = NULL; } ~ImplicitProblem() { - delete resultWriter_; + if (resultWriter_) + delete resultWriter_; }; diff --git a/dumux/implicit/mpnc/mpncmodel.hh b/dumux/implicit/mpnc/mpncmodel.hh index e8ba3bb925..f61d9d8e14 100644 --- a/dumux/implicit/mpnc/mpncmodel.hh +++ b/dumux/implicit/mpnc/mpncmodel.hh @@ -126,8 +126,15 @@ class MPNCModel : public GET_PROP_TYPE(TypeTag, BaseModel) enum {numEq = GET_PROP_VALUE(TypeTag, NumEq)}; public: + MPNCModel() + : vtkWriter_(0) + {} + ~MPNCModel() - { delete vtkWriter_; }; + { + if (vtkWriter_) + delete vtkWriter_; + } void init(Problem &problem) { -- GitLab