Fix memory leaks

* wordsplit.c (wsnode_remove): Free the removed node.  All uses changed.
This commit is contained in:
Sergey Poznyakoff 2020-06-14 02:54:08 +03:00
parent f6e2d5bd4e
commit cf2c7c86de

View file

@ -531,7 +531,7 @@ wsnode_remove (struct wordsplit *wsp, struct wordsplit_node *node)
else
wsp->ws_tail = node->prev;
node->next = node->prev = NULL;
wsnode_free (node);
}
static struct wordsplit_node *
@ -669,9 +669,8 @@ coalesce_segment (struct wordsplit *wsp, struct wordsplit_node *node)
if (p != node)
{
node->flags |= p->flags & _WSNF_QUOTE;
wsnode_remove (wsp, p);
stop = p == end;
wsnode_free (p);
wsnode_remove (wsp, p);
}
p = next;
}
@ -1787,7 +1786,6 @@ node_expand (struct wordsplit *wsp, struct wordsplit_node *node,
if (tail != node)
{
wsnode_remove (wsp, node);
wsnode_free (node);
}
return 0;
}
@ -1806,7 +1804,6 @@ wsnode_nullelim (struct wordsplit *wsp)
if (p->flags & _WSNF_NULL)
{
wsnode_remove (wsp, p);
wsnode_free (p);
}
p = next;
}
@ -2132,7 +2129,6 @@ wordsplit_pathexpand (struct wordsplit *wsp)
if (wsp->ws_options & WRDSO_NULLGLOB)
{
wsnode_remove (wsp, p);
wsnode_free (p);
}
else if (wsp->ws_options & WRDSO_FAILGLOB)
{
@ -2174,7 +2170,6 @@ wordsplit_pathexpand (struct wordsplit *wsp)
globfree (&g);
wsnode_remove (wsp, p);
wsnode_free (p);
}
}
free (pattern);