From cf2c7c86debce18ab24c038afa6dde580c9706e0 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 14 Jun 2020 02:54:08 +0300 Subject: [PATCH] Fix memory leaks * wordsplit.c (wsnode_remove): Free the removed node. All uses changed. --- wordsplit.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/wordsplit.c b/wordsplit.c index 99a8b4f..1950894 100644 --- a/wordsplit.c +++ b/wordsplit.c @@ -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);