From db5cb986ee641bfba7f13ff81397d88af7509274 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Apr 2019 16:39:14 +0100 Subject: [PATCH] Detect infinite alias self-recursion mixed with other commands, such as in the case of `alias a "echo test; a"; a`. (Unfortunately, this does not work if "wait" is used instead of "echo", but oh well) (cherry picked from commit 797ca99f42a05e6f2b491983cd7f0222b9bfc519) --- src/command.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index bd3a2243..95fd5ef4 100644 --- a/src/command.c +++ b/src/command.c @@ -543,10 +543,7 @@ static void COM_ExecuteString(char *ptext) if (!stricmp(com_argv[0], a->name)) { if (recursion > MAX_ALIAS_RECURSION) - { CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); - recursion = 0; - } else { char buf[1024]; @@ -578,8 +575,10 @@ static void COM_ExecuteString(char *ptext) } WRITESTRING(write, read); + // Monster Iestyn: keep track of how many levels of recursion we're in recursion++; COM_BufInsertText(buf); + recursion--; } return; }