From 3945daf48042084d17faddd3b7f51e320543506a Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Wed, 24 Nov 2021 14:55:29 +0100
Subject: [PATCH] [MPL] Check if scale is set in description output

This is an unusual case happening before the medium/phase/component
is fully constructed. Happend in a case where same property
was defined twice, which is OGS undefined behaviour.
---
 MaterialLib/MPL/Property.cpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/MaterialLib/MPL/Property.cpp b/MaterialLib/MPL/Property.cpp
index c2d8fcf4291..b7249e89781 100644
--- a/MaterialLib/MPL/Property.cpp
+++ b/MaterialLib/MPL/Property.cpp
@@ -140,8 +140,15 @@ PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/,
 std::string Property::description() const
 {
     return "property '" + name_ + "' defined for " +
-           std::visit([](auto&& scale) -> std::string
-                      { return scale->description(); },
-                      scale_);
+           std::visit(
+               [](auto&& scale) -> std::string
+               {
+                   if (scale == nullptr)
+                   {
+                       return "unknown scale";
+                   }
+                   return scale->description();
+               },
+               scale_);
 }
 }  // namespace MaterialPropertyLib
-- 
GitLab