Fix CI compilation issue

Resolves maybe-uninitialized error for std::function object, which shows
when compiling with optimizations.

Tested:
CI build passed.

Change-Id: Ia6f07a23715f0bf34d19e100bca94fc29cd0aa9f
Signed-off-by: Michal Orzel <michalx.orzel@intel.com>
diff --git a/src/utils/ensure.hpp b/src/utils/ensure.hpp
index 8b7567e..bb5a1e0 100644
--- a/src/utils/ensure.hpp
+++ b/src/utils/ensure.hpp
@@ -22,13 +22,13 @@
 
     ~Ensure()
     {
-        clear();
+        call();
     }
 
     template <class U>
     Ensure& operator=(U&& other)
     {
-        clear();
+        call();
         functor = std::move(other);
         return *this;
     }
@@ -37,7 +37,8 @@
 
     Ensure& operator=(std::nullptr_t)
     {
-        clear();
+        call();
+        functor = std::nullopt;
         return *this;
     }
 
@@ -49,12 +50,11 @@
     }
 
   private:
-    void clear()
+    void call()
     {
         if (functor)
         {
             (*functor)();
-            functor = std::nullopt;
         }
     }