Fixed bug in linked list where the lastnode wasn't being updated when…#383
Fixed bug in linked list where the lastnode wasn't being updated when…#383stevendargaville wants to merge 2 commits intomainfrom
Conversation
… the last value was popped off the end of the list
|
I'm a little confused: if you don't update The issue I see with the current code is that if the length of the current list is one, it never goes into the loop, so |
Yes, so I think that if you call pop_last and then immediately call insert for a non-zero length list, line 264 (node => list%lastnode) in insert will segfault?
Yes you're right, there should be a guard on the assignment of lastnode with a list of size one, I'll add that now. |
… the last value was popped off the end of the list. Causes a segfault the next time you try and access the lastnode after a pop_last.