summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/expand.c30
-rw-r--r--src/expand.h1
-rw-r--r--src/miscbltin.c2
4 files changed, 25 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c26149..a51975c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-08  Herbert Xu <herbert@gondor.apana.org.au>
+
+	* Fix ifsfirst/ifslastp leak.
+
 2010-09-08  maximilian attems <max@stro.at>
 
 	* Debug compile fix.
diff --git a/src/expand.c b/src/expand.c
index f2f964c..d6c6416 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -117,7 +117,6 @@ STATIC char *evalvar(char *, int);
 STATIC size_t strtodest(const char *, const char *, int);
 STATIC void memtodest(const char *, size_t, const char *, int);
 STATIC ssize_t varvalue(char *, int, int);
-STATIC void ifsfree(void);
 STATIC void expandmeta(struct strlist *, int);
 #ifdef HAVE_GLOB
 STATIC void addglob(const glob_t *);
@@ -191,8 +190,6 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
 
 	argbackq = arg->narg.backquote;
 	STARTSTACKSTR(expdest);
-	ifsfirst.next = NULL;
-	ifslastp = NULL;
 	argstr(arg->narg.text, flag);
 	p = _STPUTC('\0', expdest);
 	expdest = p - 1;
@@ -215,8 +212,7 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
 		*exparg.lastp = sp;
 		exparg.lastp = &sp->next;
 	}
-	if (ifsfirst.next)
-		ifsfree();
+	ifsfree();
 	*exparg.lastp = NULL;
 	if (exparg.list) {
 		*arglist->lastp = exparg.list;
@@ -1108,22 +1104,25 @@ add:
 	arglist->lastp = &sp->next;
 }
 
-STATIC void
-ifsfree(void)
+void ifsfree(void)
 {
-	struct ifsregion *p;
+	struct ifsregion *p = ifsfirst.next;
+
+	if (!p)
+		goto out;
 
 	INTOFF;
-	p = ifsfirst.next;
 	do {
 		struct ifsregion *ifsp;
 		ifsp = p->next;
 		ckfree(p);
 		p = ifsp;
 	} while (p);
-	ifslastp = NULL;
 	ifsfirst.next = NULL;
 	INTON;
+
+out:
+	ifslastp = NULL;
 }
 
 
@@ -1678,7 +1677,6 @@ casematch(union node *pattern, char *val)
 	setstackmark(&smark);
 	argbackq = pattern->narg.backquote;
 	STARTSTACKSTR(expdest);
-	ifslastp = NULL;
 	argstr(pattern->narg.text, EXP_TILDE | EXP_CASE);
 	STACKSTRNUL(expdest);
 	result = patmatch(stackblock(), val);
@@ -1718,3 +1716,13 @@ varunset(const char *end, const char *var, const char *umsg, int varflags)
 	}
 	sh_error("%.*s: %s%s", end - var - 1, var, msg, tail);
 }
+
+#ifdef mkinit
+
+INCLUDE "expand.h"
+
+RESET {
+	ifsfree();
+}
+
+#endif
diff --git a/src/expand.h b/src/expand.h
index 405af0b..4251a4a 100644
--- a/src/expand.h
+++ b/src/expand.h
@@ -70,6 +70,7 @@ int casematch(union node *, char *);
 void recordregion(int, int, int);
 void removerecordregions(int); 
 void ifsbreakup(char *, struct arglist *);
+void ifsfree(void);
 
 /* From arith.y */
 intmax_t arith(const char *);
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. */
access}TimeJune McEnroe 2018-03-05Pack message type enumsJune McEnroe 2018-03-05Undef COLOR_ constants in torus.hJune McEnroe 2018-03-05Generate tagsJune McEnroe 2017-10-03Simplify Makefile with pattern ruleJune McEnroe Insert rant about how GNU make handles the .c rule with extra dependencies. Also I don't care that everything links curses now. 2017-09-27Remove leading blank linesJune McEnroe 2017-09-27Add merge.c to READMEJune McEnroe 2017-09-03Assert client coords are valid after movementJune McEnroe 2017-09-03Relicense AGPLJune McEnroe I know it's already published under a permissive license in what is probably its final form, but I want to license it AGPL anyway on principle following some conversations I had about open source, corporations and copyleft. 2017-09-01Revert "Add client readOnly mode"June McEnroe This reverts commit 9a6c9c91c8092603b914cc0b3085d059e162ca29. 2017-09-01Remove clientRemove call from clientCastJune McEnroe If an error occurs on a client socket during a broadcast, that client will show up in the kqueue loop with EV_EOF and get removed that way. Tested by sending SIGKILL to a client and watching its cursor disappear. 2017-09-01Add client readOnly modeJune McEnroe 2017-08-31Clean up merge toolJune McEnroe Choose the version with the most recent access if the modify times are the same. 2017-08-31Choose B for tiles with equal modify timesJune McEnroe This way newer access counts and times will be preserved. 2017-08-31Add quick data file merge toolJune McEnroe Hopefully I won't have to use it ever again. 2017-08-30Use only foreground color for selecting spawnJune McEnroe 2017-08-29Add four additional spawnsJune McEnroe 2017-08-28Add respawningJune McEnroe 2017-08-26Move license above includesJune McEnroe Why was it down there? 2017-08-26Snapshot metadataJune McEnroe 2017-08-26Add meta.c to READMEJune McEnroe 2017-08-26Use MakefileJune McEnroe