Commit ea60dfcb authored by Florian Sattler's avatar Florian Sattler Committed by Commit Bot

[base] Fix wrong ThreadedList append for empty lists allocated on the stack.

Change-Id: Ieae88990f3d960c13a2bafc223e12061e994fce0
Reviewed-on: https://chromium-review.googlesource.com/c/1270580Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#56474}
parent 493c894a
......@@ -69,6 +69,8 @@ class ThreadedListBase final : public BaseClass {
}
void Append(ThreadedListBase&& list) {
if (list.is_empty()) return;
*tail_ = list.head_;
tail_ = list.tail_;
list.Clear();
......
......@@ -166,6 +166,23 @@ TEST_F(ThreadedListTest, Append) {
CHECK_EQ(list.end(), initial_extra_list_end);
}
TEST_F(ThreadedListTest, AppendOutOfScope) {
ThreadedListTestNode local_extra_test_node_0;
CHECK_EQ(list.LengthForTest(), 5);
{
ThreadedList<ThreadedListTestNode, ThreadedListTestNode::OtherTraits>
scoped_extra_test_list;
list.Append(std::move(scoped_extra_test_list));
}
list.Add(&local_extra_test_node_0);
list.Verify();
CHECK_EQ(list.LengthForTest(), 6);
CHECK_EQ(list.AtForTest(4), &nodes[4]);
CHECK_EQ(list.AtForTest(5), &local_extra_test_node_0);
}
TEST_F(ThreadedListTest, Prepend) {
CHECK_EQ(list.LengthForTest(), 5);
list.Prepend(std::move(extra_test_list));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment