Skip to content

Commit

Permalink
Test: fix undefined behaviour in ListUnitTest
Browse files Browse the repository at this point in the history
The `test_multilinik_round` test scenario of ListUnitTest uses a reference
to a `vector` element that is invalidated after a `vector::emplace_back`
call. Fix this by calling `vector::emplace_back` after using the referenced
element.
  • Loading branch information
CuriousGeorgiy committed Nov 22, 2023
1 parent 9e4ba13 commit 56b9952
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/ListUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,12 +1162,12 @@ void test_multilinik_round()
bool red_before = 0 != (r & 1);
bool green_before = 0 != (r & 2);
bool blue_before = 0 != (r & 4);
objects.emplace_back(id, near,
red_before, green_before, blue_before);

expected_insert_near(expected_red, red_before, near.m_Data, id);
expected_insert_near(expected_green, green_before, near.m_Data, id);
expected_insert_near(expected_blue, blue_before, near.m_Data, id);

objects.emplace_back(id, near, red_before, green_before, blue_before);
};

auto insert_to_list = [&]() {
Expand Down

0 comments on commit 56b9952

Please sign in to comment.