From f60d476b2af5e7842ad92b5bd0fcb44a502d149c Mon Sep 17 00:00:00 2001
From: Nick Draper <nick.draper@stfc.ac.uk>
Date: Tue, 13 Oct 2015 11:34:14 +0100
Subject: [PATCH] First pass of null pointer derefs

re #13938
---
 Framework/Algorithms/src/CorelliCrossCorrelate.cpp | 6 ++++++
 Framework/MDAlgorithms/src/FindPeaksMD.cpp         | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp
index a6e0cb33adf..d65a6070081 100644
--- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp
+++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp
@@ -168,6 +168,12 @@ void CorelliCrossCorrelate::exec() {
   // Determine period from chopper frequency.
   auto motorSpeed = dynamic_cast<TimeSeriesProperty<double> *>(
       inputWS->run().getProperty("BL9:Chop:Skf4:MotorSpeed"));
+  if (!motorSpeed)
+  {
+    throw Exception::NotFoundError(
+      "Could not find a log value for the motor speed",
+      "BL9:Chop:Skf4:MotorSpeed");
+  }
   double period = 1e9 / static_cast<double>(motorSpeed->timeAverageValue());
   g_log.information() << "Frequency = " << 1e9 / period
                       << "Hz Period = " << period << "ns\n";
diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp
index 1e94707a155..988f5b7f297 100644
--- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp
+++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp
@@ -215,12 +215,15 @@ FindPeaksMD::createPeak(const Mantid::Kernel::V3D &Q, const double binCount) {
   boost::shared_ptr<DataObjects::Peak> p;
   if (dimType == QLAB) {
     // Build using the Q-lab-frame constructor
-    p = boost::shared_ptr<DataObjects::Peak>(new Peak(inst, Q));
+    p = boost::make_shared<Peak>(inst, Q);
     // Save gonio matrix for later
     p->setGoniometerMatrix(m_goniometer);
   } else if (dimType == QSAMPLE) {
     // Build using the Q-sample-frame constructor
-    p = boost::shared_ptr<DataObjects::Peak>(new Peak(inst, Q, m_goniometer));
+    p = boost::make_shared<Peak>(inst, Q, m_goniometer);
+  } else  {
+    throw std::invalid_argument(
+      "Cannot Integrate peaks unless the dimension is QLAB or QSAMPLE");
   }
 
   try { // Look for a detector
-- 
GitLab