From fea27143e9db0812ed433372255214449d3cb8ab Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 16 Sep 2021 14:02:39 +0100 Subject: [PATCH] LibJS: Initialize value in ThrowCompletionOr default constructor Otherwise, TRY() will crash when calling release_value() on the empty m_value Optional. --- Userland/Libraries/LibJS/Runtime/Completion.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/Completion.h b/Userland/Libraries/LibJS/Runtime/Completion.h index e84c9870c4..bf70d75ff2 100644 --- a/Userland/Libraries/LibJS/Runtime/Completion.h +++ b/Userland/Libraries/LibJS/Runtime/Completion.h @@ -97,7 +97,10 @@ private: template class [[nodiscard]] ThrowCompletionOr { public: - ThrowCompletionOr() requires(IsSame) = default; + ThrowCompletionOr() requires(IsSame) + : m_value(Empty {}) + { + } // Not `explicit` on purpose so that `return vm.throw_completion(...);` is possible. ThrowCompletionOr(Completion throw_completion)