Hi all. I'm trying to build up a linked list from strings that are stored in nodes from a trie here: https://github.com/Ttibsi/autosuggest/blob/main/main.c#L46-L72. I'm running into a problem where after running for a bit, the code is hanging on this function that checks the length of the linked list: https://github.com/Ttibsi/autosuggest/blob/main/dll.h#L39-L47, although I can't really tell what is causing it. Going through GDB, I can see that at some point, there's a node that still has a next set, but no word stored in it. I'm not sure why this is happening, and I've tried changing dll.h:41 to looking for if n->word != NULL instead of how it currently is (checking for a not null next pointer).
(gdb) p *n
$2 = {next = 0x7fea51a750, prev = 0x0, word = 0x6c8beed8 "placability", word_len = 0, selected = false}
(gdb) p *n->next
$3 = {next = 0x7fea51a7b0, prev = 0x53298ad0, word = 0x0, word_len = 0, selected = false}
It looks like this gets set potentially at a previous point, although I don't know where a string copy into the linked list node wouldn't work properly (I'm assuming the pointer just isn't passed over?)
If anyone's able to take a look through and see if they can spot anything wrong here? I'm pretty new to C specifically, so if there's anything that could be done better, I'm up for any feedback. Thank you