From 25f3f95f91f048265d7ae7b066c5576f2c34e48c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Thu, 30 Nov 2023 10:43:34 +0100
Subject: [PATCH] corr memory leak

---
 .clang-tidy                   | 12 ++++++++----
 Resample/Processed/Slicer.cpp |  6 +++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy
index 666b0f684a9..a49ce5952f8 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -23,10 +23,13 @@ Checks: '*,
 -clang-analyzer-core.CallAndMessage,
 -clang-analyzer-optin.cplusplus.VirtualCall,
 -cppcoreguidelines-pro-type-const-cast,
--cppcoreguidelines-pro-type-static-cast-downcast,
--google-runtime-references,
--misc-non-private-member-variables-in-classes,
-modernize-loop-convert,
+cppcoreguidelines-pro-type-static-cast-downcast,
+
+-*-use-auto,
+-*-use-emplace,
+-*-use-equals-default,
+-*-use-nullptr,
+-*-use-override,
 
 -bugprone-unused-return-value,
 -cppcoreguidelines-explicit-virtual-functions,
@@ -36,6 +39,7 @@ modernize-loop-convert,
 -llvm-qualified-auto,
 -misc-uniqueptr-reset-release,
 -modernize-avoid-bind,
+-modernize-loop-convert,
 -modernize-make-unique,
 -modernize-pass-by-value,
 -modernize-use-default-member-init,
diff --git a/Resample/Processed/Slicer.cpp b/Resample/Processed/Slicer.cpp
index 31d682032f7..54b4a4402f6 100644
--- a/Resample/Processed/Slicer.cpp
+++ b/Resample/Processed/Slicer.cpp
@@ -124,13 +124,13 @@ IFormFactor* doSlice(const IFormFactor* ff, double dz_bottom, double dz_top)
 ReParticle* createParticleSlice(const IFormFactor* ff, ZLimits limits, const R3& position,
                                 const IRotation* rot)
 {
-    const RotMatrix* rotMatrix =
-        rot && !rot->isIdentity() ? new RotMatrix(rot->rotMatrix()) : nullptr;
     const Span span = ff->spanZ(rot) + position.z();
-
     if (span.hig() <= limits.low() || span.low() >= limits.hig())
         return nullptr;
 
+    const RotMatrix* rotMatrix =
+        rot && !rot->isIdentity() ? new RotMatrix(rot->rotMatrix()) : nullptr;
+
     if (limits.low() <= span.low() && span.hig() <= limits.hig())
         return new ReParticle(ff->clone(), new R3(position), rotMatrix);
 
-- 
GitLab