From a2eb0de91aac2ca287868a02f7a75b4562a7f5c6 Mon Sep 17 00:00:00 2001
From: Samuel Jackson <samueljackson@outlook.com>
Date: Mon, 15 Jan 2018 10:26:55 +0000
Subject: [PATCH] Fix crash when saving peaks workspace.

If for some reason one of the radii is not defined SaveNexus crashes
because we access the value without checking it first. We should just
check that both radii are present, then write them out.

(cherry picked from commit 5e7dc01597680694128a3897d2244238f17e145a)
---
 Framework/DataObjects/src/PeakShapeSpherical.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/Framework/DataObjects/src/PeakShapeSpherical.cpp b/Framework/DataObjects/src/PeakShapeSpherical.cpp
index 1e79b6af19d..68e65e66e9c 100644
--- a/Framework/DataObjects/src/PeakShapeSpherical.cpp
+++ b/Framework/DataObjects/src/PeakShapeSpherical.cpp
@@ -53,13 +53,10 @@ std::string PeakShapeSpherical::toJSON() const {
   Json::Value root;
   PeakShapeBase::buildCommon(root);
   root["radius"] = Json::Value(m_radius);
-  // Check that there is an inner radius before writing
-  if (m_backgroundInnerRadius.is_initialized()) {
+
+  if (m_backgroundInnerRadius && m_backgroundOuterRadius) {
     root["background_outer_radius"] =
         Json::Value(m_backgroundOuterRadius.get());
-  }
-  // Check that there is an outer radius before writing
-  if (m_backgroundOuterRadius.is_initialized()) {
     root["background_inner_radius"] =
         Json::Value(m_backgroundInnerRadius.get());
   }
-- 
GitLab