d57a58d
--- a/check.t	2010/07/19 22:41:01	1.383
d57a58d
+++ b/check.t	2010/07/21 11:31:13	1.384
d57a58d
@@ -184,6 +184,17 @@ stdin:
d57a58d
 expected-stdout:
d57a58d
 	tf
d57a58d
 	tf
d57a58d
+---
d57a58d
+name: alias-10
d57a58d
+description:
d57a58d
+	Check that recursion is detected/avoided in aliases.
d57a58d
+	Regression, introduced during an old bugfix.
d57a58d
+stdin:
d57a58d
+	alias foo='print hello '
d57a58d
+	alias bar='foo world'
d57a58d
+	echo $(bar)
d57a58d
+expected-stdout:
d57a58d
+	hello world
d57a58d
 ---
d57a58d
 name: arith-lazy-1
d57a58d
 description:
d57a58d
--- a/lex.c	2010/07/17 22:09:36	1.116
d57a58d
+++ b/lex.c	2010/07/21 11:31:15	1.117
d57a58d
@@ -1110,7 +1110,7 @@ yylex(int cf)
d57a58d
 			else {
d57a58d
 				Source *s = source;
d57a58d
 
d57a58d
-				while (s->flags & SF_HASALIAS)
d57a58d
+				while (s && (s->flags & SF_HASALIAS))
d57a58d
 					if (s->u.tblp == p)
d57a58d
 						return (LWORD);
d57a58d
 					else