From c0810e3c0226efaf362419ea3a8d1f6d7f74ca20 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 26 May 2006 22:45:45 +0000 Subject: 22464: bad recursion if error in prompt substitution --- Src/Zle/zle_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index c6e374bc7..69e88c8b4 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1342,10 +1342,15 @@ recursiveedit(UNUSED(char **args)) void reexpandprompt(void) { - free(lpromptbuf); - lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL); - free(rpromptbuf); - rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL); + static reexpanding; + + if (!reexpanding++) { + free(lpromptbuf); + lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL); + free(rpromptbuf); + rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL); + } + reexpanding--; } /**/ -- cgit 1.4.1