diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-06-14 02:54:08 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-06-14 02:54:08 +0300 |
commit | cf2c7c86debce18ab24c038afa6dde580c9706e0 (patch) | |
tree | 75db3231aabca76878d0257fbcfbdb7db3dd0200 | |
parent | f6e2d5bd4ef0b83785d6a356418ef284ebc4b7c6 (diff) | |
download | wordsplit-cf2c7c86debce18ab24c038afa6dde580c9706e0.tar.gz wordsplit-cf2c7c86debce18ab24c038afa6dde580c9706e0.tar.bz2 |
Fix memory leaksv1.1
* wordsplit.c (wsnode_remove): Free the removed node. All uses changed.
-rw-r--r-- | wordsplit.c | 9 |
1 files 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) | |||
531 | else | 531 | else |
532 | wsp->ws_tail = node->prev; | 532 | wsp->ws_tail = node->prev; |
533 | 533 | ||
534 | node->next = node->prev = NULL; | 534 | wsnode_free (node); |
535 | } | 535 | } |
536 | 536 | ||
537 | static struct wordsplit_node * | 537 | static struct wordsplit_node * |
@@ -669,9 +669,8 @@ coalesce_segment (struct wordsplit *wsp, struct wordsplit_node *node) | |||
669 | if (p != node) | 669 | if (p != node) |
670 | { | 670 | { |
671 | node->flags |= p->flags & _WSNF_QUOTE; | 671 | node->flags |= p->flags & _WSNF_QUOTE; |
672 | wsnode_remove (wsp, p); | ||
673 | stop = p == end; | 672 | stop = p == end; |
674 | wsnode_free (p); | 673 | wsnode_remove (wsp, p); |
675 | } | 674 | } |
676 | p = next; | 675 | p = next; |
677 | } | 676 | } |
@@ -1787,7 +1786,6 @@ node_expand (struct wordsplit *wsp, struct wordsplit_node *node, | |||
1787 | if (tail != node) | 1786 | if (tail != node) |
1788 | { | 1787 | { |
1789 | wsnode_remove (wsp, node); | 1788 | wsnode_remove (wsp, node); |
1790 | wsnode_free (node); | ||
1791 | } | 1789 | } |
1792 | return 0; | 1790 | return 0; |
1793 | } | 1791 | } |
@@ -1806,7 +1804,6 @@ wsnode_nullelim (struct wordsplit *wsp) | |||
1806 | if (p->flags & _WSNF_NULL) | 1804 | if (p->flags & _WSNF_NULL) |
1807 | { | 1805 | { |
1808 | wsnode_remove (wsp, p); | 1806 | wsnode_remove (wsp, p); |
1809 | wsnode_free (p); | ||
1810 | } | 1807 | } |
1811 | p = next; | 1808 | p = next; |
1812 | } | 1809 | } |
@@ -2132,7 +2129,6 @@ wordsplit_pathexpand (struct wordsplit *wsp) | |||
2132 | if (wsp->ws_options & WRDSO_NULLGLOB) | 2129 | if (wsp->ws_options & WRDSO_NULLGLOB) |
2133 | { | 2130 | { |
2134 | wsnode_remove (wsp, p); | 2131 | wsnode_remove (wsp, p); |
2135 | wsnode_free (p); | ||
2136 | } | 2132 | } |
2137 | else if (wsp->ws_options & WRDSO_FAILGLOB) | 2133 | else if (wsp->ws_options & WRDSO_FAILGLOB) |
2138 | { | 2134 | { |
@@ -2174,7 +2170,6 @@ wordsplit_pathexpand (struct wordsplit *wsp) | |||
2174 | globfree (&g); | 2170 | globfree (&g); |
2175 | 2171 | ||
2176 | wsnode_remove (wsp, p); | 2172 | wsnode_remove (wsp, p); |
2177 | wsnode_free (p); | ||
2178 | } | 2173 | } |
2179 | } | 2174 | } |
2180 | free (pattern); | 2175 | free (pattern); |