summary refs log tree commit diff
path: root/src/miscbltin.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-09-08 20:07:26 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2010-09-08 20:07:26 +0800
commitf42e443bb511ed3224f09b4fcf0772438ebdbbfa (patch)
treefc2523d1f399d4d4a8a6432e3855de649ddf7346 /src/miscbltin.c
parent[JOBS] Debug compile fix (diff)
downloaddash-f42e443bb511ed3224f09b4fcf0772438ebdbbfa.tar.gz
dash-f42e443bb511ed3224f09b4fcf0772438ebdbbfa.zip
[EXPAND] Fix ifsfirst/ifslastp leak
As it stands expandarg may return with a non-NULL ifslastp which
then confuses any subsequent ifsbreakup user that doesn't clear
it directly.

What's worse, if we get interrupted before we hit ifsfree in
expandarg we will leak memory.

This patch fixes this by always calling ifsfree in expandarg
thus ensuring that ifslastp is always NULL on the normal path.
It also adds an ifsfree call to the RESET path to ensure that
memory isn't leaked.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src/miscbltin.c')
-rw-r--r--src/miscbltin.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/miscbltin.c b/src/miscbltin.c
index 5ab1648..c42a01c 100644
--- a/src/miscbltin.c
+++ b/src/miscbltin.c
@@ -89,7 +89,7 @@ readcmd_handle_line(char *line, char **ap, size_t len)
 	
 	ifsbreakup(s, &arglist);
 	*arglist.lastp = NULL;
-	removerecordregions(0);
+	ifsfree();
 
 	for (sl = arglist.list; sl; sl = sl->next) {
 		/* remaining fields present, but no variables left. */