diff --git a/Framework/API/src/MDFrameValidator.cpp b/Framework/API/src/MDFrameValidator.cpp
index f8968c71e10bbeab428c9e932242a25f34579323..e80d0e6f442ed1b2137bcb0d40a22a1f412d90c7 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.";
   }