diff --git a/inkcpp/globals_impl.h b/inkcpp/globals_impl.h index d9f8a303..06c787d6 100644 --- a/inkcpp/globals_impl.h +++ b/inkcpp/globals_impl.h @@ -36,7 +36,12 @@ class globals_impl final // Initializes a new global store from the given story globals_impl(const story_impl*); - virtual ~globals_impl() {} + virtual ~globals_impl() + { + for (const auto& callback : _callbacks) { + delete callback.operation; + } + } snapshot* create_snapshot() const override; diff --git a/inkcpp/include/functional.h b/inkcpp/include/functional.h index a0e4fd9a..11b577a4 100644 --- a/inkcpp/include/functional.h +++ b/inkcpp/include/functional.h @@ -26,6 +26,7 @@ class callback_base { public: virtual void call(ink::runtime::value, ink::optional) = 0; + virtual ~callback_base() = default; }; template @@ -313,8 +314,8 @@ class function_array_delegate : public function_base char* ptr = buffer; while (*src != '\0') *(ptr++) = *(src++); - *ptr = 0; - result = ink::runtime::value(buffer); + *ptr = 0; + result = ink::runtime::value(buffer); } push(stack, result); }