-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
I encountered a dangling pointer problem in the function r_utils_linklist_pop when I implemented the project.
void* r_utils_list_pop(r_utils_linklist_s *l) {
r_utils_linklist_cell_s *c;
void *elem;
assert(l != NULL);
if(l->head == NULL)
return NULL;
c = l->tail;
elem = c->elem;
l->tail = c->prev;
if(l->tail == NULL)
l->head = NULL;
free(c);
l->num--;
return elem;
}And I think I should set l->tail->next = NULL if l->tail != NULL when I pop an element.
if (l->tail == NULL) l->head = NULL;
else l->tail->next = NULL;Metadata
Metadata
Assignees
Labels
No labels