diff --git a/luna/include/luna/LinkedList.h b/luna/include/luna/LinkedList.h index bfb1f2de..cb2e6c66 100644 --- a/luna/include/luna/LinkedList.h +++ b/luna/include/luna/LinkedList.h @@ -49,12 +49,14 @@ template class LinkedListNode { end_node->m_next_node = this; this->m_last_node = end_node; + this->m_next_node = nullptr; } void prepend_to_list(SelfType* start_node) { start_node->m_last_node = this; this->m_next_node = start_node; + this->m_last_node = nullptr; } friend class LinkedList; @@ -104,6 +106,8 @@ template class LinkedList if (m_end_node == base_node) m_end_node = new_node; + if (base_node->get_next()) base_node->get_next()->set_last(new_node); + new_node->set_next(base_node->get_next()); base_node->set_next(new_node); new_node->set_last(base_node);