diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-16 14:02:39 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-16 22:34:24 +0100 |
commit | fea27143e9db0812ed433372255214449d3cb8ab (patch) | |
tree | 5ce414175346f5f4c2024c8f9980984fcc7f40fb /Userland/Libraries | |
parent | 5f0f0ac413ef561b005398756544dd22c4321b05 (diff) | |
download | serenity-fea27143e9db0812ed433372255214449d3cb8ab.zip |
LibJS: Initialize value in ThrowCompletionOr<void> default constructor
Otherwise, TRY() will crash when calling release_value() on the empty
m_value Optional.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Completion.h | 5 |
1 files changed, 4 insertions, 1 deletions
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<typename ValueType> class [[nodiscard]] ThrowCompletionOr { public: - ThrowCompletionOr() requires(IsSame<ValueType, Empty>) = default; + ThrowCompletionOr() requires(IsSame<ValueType, Empty>) + : m_value(Empty {}) + { + } // Not `explicit` on purpose so that `return vm.throw_completion<Error>(...);` is possible. ThrowCompletionOr(Completion throw_completion) |