[gmime-devel] g_mime_header_list_clear leaving a list in limbo



Dear all,

I want to reorder the headers in a particular order. The easiest is to extract all headers, order them, clear the headerlist with g_mime_header_list_clear and append the headers again in the desired order with g_mime_header_list_append. Problem is that I'm getting a sigsegv when calling g_mime_header_list_append (the 4th or 5th line). When appending to a headerlist created with g_mime_header_list_new there is no problem and when I do a g_mime_header_iter_remove for the complete list, there is no problem either. Looking in the sources I see that there is a loop over next = header->next; ... header = next; until header NULL. But afaiu this leaves list->tailpred pointing to a released node.

Also when deleting all headers with g_mime_header_iter_remove, iter is not invalidated and while g_mime_header_iter_first returns false, g_mime_header_iter_last returns true indicating that tailpred isn't updated neither. g_mime_header_iter_get_name returns a random value after g_mime_header_iter_last. This seems to indicate that my "deleting all headers with g_mime_header_iter_remove" workaround isn't that reliable and crash prone at one point.

Unrelated but kinda surprising to find that g_mime_header_list_prepend calls list_append instead of list_prepend. The hash table is updated to point to the newly added header but it is last in the headerlist.

thanks, Ludo



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]