From 689d9bc6a5776f54995b68ad2493652f55b9d419 Mon Sep 17 00:00:00 2001 From: ggn Date: Fri, 30 Oct 2015 19:30:21 +0200 Subject: [PATCH] Fix for bug that happened when a called macro inside an if/endif block would have a syntax error: the assembler would get stuck in an infinite loop (Error: mismatched .endif) --- macro.c | 3 +-- token.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/macro.c b/macro.c index e7d51dd..0807e74 100644 --- a/macro.c +++ b/macro.c @@ -80,8 +80,7 @@ of another (nested macros). Need to fix that somehow. argp -= imacro->im_nargs; DEBUG printf("%d (nargs = %d)\n", argp, imacro->im_nargs); - fpop(); - return 0; + return fpop(); } diff --git a/token.c b/token.c index cc754ab..c78d97a 100644 --- a/token.c +++ b/token.c @@ -728,7 +728,10 @@ int fpop(void) // Pop IFENT levels until we reach the conditional assembly context we // were at when the input object was entered. while (ifent != inobj->in_ifent) - d_endif(); + { + if (d_endif() != 0) // Something bad happened during endif parsing? + return -1; // If yes, bail instead of getting stuck in a loop + } tok = inobj->in_otok; // Restore tok and otok etok = inobj->in_etok; @@ -940,8 +943,10 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); case SRC_IMACRO: if ((ln = GetNextMacroLine()) == NULL) { - ExitMacro(); // Exit macro (pop args, do fpop(), etc) - goto retry; // Try for more lines... + if (ExitMacro() == 0) // Exit macro (pop args, do fpop(), etc) + goto retry; // Try for more lines... + else + return TKEOF; // Oops, we got a non zero return code, signal EOF } lntag = '@'; -- 2.37.2