diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index eb3dd2bcb708298f5247aef3d93ab8ddf84dbed2..9f6455ce838e98a8eabfbf47f3342417b64dd821 100755
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -116,7 +116,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
 				if (c) {
 					*c = '\0';
 					c++;
-					while(*c < 33)
+					while ((*c) && (*c < 33))
 						c++;
 #if 0
 					printf("'%s' is '%s' at line %d\n", buf, c, lineno);