From 2ebec4aa8f7a72ff478a9bc27264edc33da859e9 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Tue, 21 Jan 2025 16:43:22 +0100 Subject: [PATCH] Do not read 'destructed' memory. Fixes VECGEOM-624. https://its.cern.ch/jira/browse/VECGEOM-624 --- VecGeom/base/VariableSizeObj.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VecGeom/base/VariableSizeObj.h b/VecGeom/base/VariableSizeObj.h index 0249a66a5..736b4e2d7 100644 --- a/VecGeom/base/VariableSizeObj.h +++ b/VecGeom/base/VariableSizeObj.h @@ -178,8 +178,9 @@ public: static void ReleaseInstance(Cont *obj) { // Releases the space allocated for the object + bool selfalloc = obj->GetVariableData().fSelfAlloc; obj->~Cont(); - if (obj->GetVariableData().fSelfAlloc) delete[](char *) obj; + if (selfalloc) delete[] (char *)obj; } // Equivalent of sizeof function (not taking into account padding for alignment) -- GitLab