From e3f5f0a801f2fc5c2b43a536af008bf722114643 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 4 Nov 2017 19:08:49 +0100 Subject: [PATCH] Delete initializer, if it could not be stored. --- include/MUtils/Lazy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/MUtils/Lazy.h b/include/MUtils/Lazy.h index 0040072..4c31051 100644 --- a/include/MUtils/Lazy.h +++ b/include/MUtils/Lazy.h @@ -52,9 +52,9 @@ namespace MUtils { if (T *const initializer = create()) { - if (m_data.testAndSetOrdered(NULL, initializer)) + if (!m_data.testAndSetOrdered(NULL, initializer)) { - return *initializer; + delete initializer; } } else