1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 11:57:36 +00:00

AK: Fix leak in Optional(Optional&&)

We were *copying* the other Optional's value and then marking it as not
having a value. This prevented us from ever destroying the original.
This commit is contained in:
Andreas Kling 2019-08-05 22:27:47 +02:00
parent 9553ecfe01
commit 151e6a1818
2 changed files with 14 additions and 1 deletions

View file

@ -29,7 +29,7 @@ public:
: m_has_value(other.m_has_value)
{
if (m_has_value) {
new (&m_storage) T(move(other.value_without_consume_state()));
new (&m_storage) T(other.release_value());
other.m_has_value = false;
}
}