examples/x11.c: fix invalid removal of first list element
Fix use of memory after it was being freed. Detected by clang scan in line 56, column 12.
This commit is contained in:
parent
3e47ca8a32
commit
477e609a84
@ -48,13 +48,13 @@ static void remove_node(struct chan_X11_list *elem)
|
|||||||
current_node = gp_x11_chan;
|
current_node = gp_x11_chan;
|
||||||
|
|
||||||
if (gp_x11_chan == elem) {
|
if (gp_x11_chan == elem) {
|
||||||
/* Removing the only one element in the list */
|
gp_x11_chan = gp_x11_chan->next;
|
||||||
free(gp_x11_chan);
|
free(current_node);
|
||||||
gp_x11_chan = NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( current_node->next != NULL) {
|
while (current_node->next != NULL) {
|
||||||
if (current_node->next ==elem) {
|
if (current_node->next == elem) {
|
||||||
current_node->next = current_node->next->next;
|
current_node->next = current_node->next->next;
|
||||||
current_node = current_node->next;
|
current_node = current_node->next;
|
||||||
free(current_node);
|
free(current_node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user