From b35be4eadc0637e34238a77b60d0c8e50786cdcd Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@gmail.com>
Date: Sun, 18 Nov 2018 21:04:56 +0000
Subject: [PATCH] Fix heap-use-after-free bug

getDimension() returns a shared_ptr that is immediately
deleted which caused frame to become dangling reference.
---
 Framework/API/src/MDFrameValidator.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Framework/API/src/MDFrameValidator.cpp b/Framework/API/src/MDFrameValidator.cpp
index f8968c71e10..e80d0e6f442 100644
--- a/Framework/API/src/MDFrameValidator.cpp
+++ b/Framework/API/src/MDFrameValidator.cpp
@@ -36,8 +36,8 @@ std::string
 MDFrameValidator::checkValidity(const IMDWorkspace_sptr &workspace) const {
 
   for (size_t index = 0; index < workspace->getNumDims(); ++index) {
-    const auto &frame = workspace->getDimension(index)->getMDFrame();
-    if (frame.name() != m_frameID)
+    const auto dimension = workspace->getDimension(index);
+    if (dimension->getMDFrame().name() != m_frameID)
       return "MDWorkspace must be in the " + m_frameID + " frame.";
   }
 
-- 
GitLab