diff --git a/src/include/containers/BlockingList.hpp b/src/include/containers/BlockingList.hpp index 27e3f896cf..0a68f783f3 100644 --- a/src/include/containers/BlockingList.hpp +++ b/src/include/containers/BlockingList.hpp @@ -68,7 +68,7 @@ public: return List::remove(removeNode); } - size_t size() const + size_t size() { LockGuard lg{_mutex}; return List::size(); diff --git a/src/include/containers/List.hpp b/src/include/containers/List.hpp index c005cf17a4..5cf7447beb 100644 --- a/src/include/containers/List.hpp +++ b/src/include/containers/List.hpp @@ -70,7 +70,13 @@ public: { // base case if (removeNode == _head) { - _head = nullptr; + if (_head->getSibling() != nullptr) { + _head = _head->getSibling(); + + } else { + _head = nullptr; + } + return true; } diff --git a/src/systemcmds/tests/test_List.cpp b/src/systemcmds/tests/test_List.cpp index 5baabde5d9..14936410d6 100644 --- a/src/systemcmds/tests/test_List.cpp +++ b/src/systemcmds/tests/test_List.cpp @@ -141,6 +141,8 @@ bool ListTest::test_remove() for (auto t : list1) { ut_assert_true(t->i != remove_i); } + + ut_assert_true(list1.size() == 100 - remove_i - 1); } // list should now be empty