The curses interface maintains message history in a doubly linked list with a capacity limit. Once capacity is reached, the list head is advanced and the old head discarded, but it was leaving the new head's 'previous element' link pointing at that discarded element. tmp_mesg = first_mesg->next_mesg; (at this stage, tmp_mesg->prev_mesg points at first_mesg), free(first_mesg); first_mesg = tmp_mesg; (with necessary 'first_mesg->prev_msg = NULL' missing). The situation wasn't a significant problem because traversing the list was limited by a counter. Going from tail back to head exhausted the counter without ever accessing the stale pointer. Since it wasn't noticeable, I haven't added a fixes entry for this. I've also changed it to do fewer memory allocations and frees by reusing the old list head instead of always allocating a new element and freeing the one being replaced.
20 KiB
20 KiB