summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-15 09:12:12 +0000
committerTim Flynn <trflynn89@pm.me>2022-12-15 06:56:37 -0500
commit029db614e3c04279b9ae6c7e21e07baeccad63fd (patch)
tree4154b80aabcf6cb4e63cc9b6aa69ef3bdc3eafde
parent0991464de681f460c5ffdbe17444f0d5d52052e7 (diff)
downloadserenity-029db614e3c04279b9ae6c7e21e07baeccad63fd.zip
LibJS: Ensure Optional<Completion>'s defaults to empty completion
Default-constructing the m_value Completion made it have an undefined JS value when not overridden in a constructor, such as the conditional initialization in Optional(Optional<JS::Completion> const&). See investigation by Tim here: https://github.com/SerenityOS/serenity/pull/16498#discussion_r1049090456 Co-authored-by: Timothy Flynn <trflynn89@pm.me>
-rw-r--r--Userland/Libraries/LibJS/Runtime/Completion.h7
1 files changed, 2 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Completion.h b/Userland/Libraries/LibJS/Runtime/Completion.h
index 0367d25727..1ca4fa4260 100644
--- a/Userland/Libraries/LibJS/Runtime/Completion.h
+++ b/Userland/Libraries/LibJS/Runtime/Completion.h
@@ -131,10 +131,7 @@ class Optional<JS::Completion> {
public:
using ValueType = JS::Completion;
- Optional()
- : m_value(JS::Completion(JS::Completion::EmptyTag {}))
- {
- }
+ Optional() = default;
Optional(Optional<JS::Completion> const& other)
{
@@ -228,7 +225,7 @@ public:
JS::Completion* operator->() { return &value(); }
private:
- JS::Completion m_value;
+ JS::Completion m_value { JS::Completion::EmptyTag {} };
};
}