mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
AK+Tests: Don't double-destroy NoAllocationGuard in TestFixedArray
This caused the m_allocation_enabled_previously member to be technically uninitialized when the compiler emits the implicit destructor call for stack allocated classes. This was pointed out by gcc on lagom builds, no clue how this was flying under the radar for so long and is not triggering CI.
This commit is contained in:
parent
7bb8d26b0c
commit
6b6510b577
Notes:
sideshowbarker
2024-07-17 07:08:45 +09:00
Author: https://github.com/Hendiadyoin1
Commit: 6b6510b577
Pull-request: https://github.com/SerenityOS/serenity/pull/15199
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 9 additions and 4 deletions
|
@ -63,10 +63,15 @@ TEST_CASE(no_allocation)
|
|||
|
||||
EXPECT_NO_CRASH("Move", [&] {
|
||||
FixedArray<int> moved_from_array = FixedArray<int>::must_create_but_fixme_should_propagate_errors(6);
|
||||
NoAllocationGuard guard;
|
||||
FixedArray<int> moved_to_array(move(moved_from_array));
|
||||
// We need to ensure that this destructor runs before the FixedArray destructor.
|
||||
guard.~NoAllocationGuard();
|
||||
// We need an Optional here to ensure that the NoAllocationGuard is
|
||||
// destroyed before the moved_to_array, because that would call free
|
||||
Optional<FixedArray<int>> moved_to_array;
|
||||
|
||||
{
|
||||
NoAllocationGuard guard;
|
||||
moved_to_array.emplace(move(moved_from_array));
|
||||
}
|
||||
|
||||
return Test::Crash::Failure::DidNotCrash;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue