From: Arran Cudbard-Bell Date: Tue, 21 Nov 2017 14:49:04 +0000 (+0000) Subject: Check for an attempt to pop the top frame and deal with that explicitly by breaking... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fcc1cfe7928a10d3fa362dee9d31392ee163877;p=thirdparty%2Ffreeradius-server.git Check for an attempt to pop the top frame and deal with that explicitly by breaking out the interpreter loop This allows the function to return at the right point without decrementing stack->depth --- diff --git a/src/main/unlang_interpret.c b/src/main/unlang_interpret.c index e560ae1224d..6aee2c004f0 100644 --- a/src/main/unlang_interpret.c +++ b/src/main/unlang_interpret.c @@ -2425,7 +2425,7 @@ static rlm_rcode_t unlang_run(REQUEST *request) RDEBUG4("** [%i] %s - interpreter entered", stack->depth, __FUNCTION__); - do { + for (;;) { switch (fa) { case UNLANG_FRAME_ACTION_CONTINUE: /* Evaluate the current frame */ priority = -1; @@ -2435,6 +2435,14 @@ static rlm_rcode_t unlang_run(REQUEST *request) frame = &stack->frame[stack->depth]; fa = unlang_frame_eval(request, frame, &result, &priority); + + /* + * We were executing a frame, unlang_frame_eval() + * indicated we should pop it, but we're now at + * a top_frame, so we need to break out of the loop + * and calculate the final result for this substack. + */ + if ((fa == UNLANG_FRAME_ACTION_POP) && frame->top_frame) break; /* return */ continue; case UNLANG_FRAME_ACTION_POP: /* Pop this frame and check the one beneath it */ @@ -2507,7 +2515,7 @@ static rlm_rcode_t unlang_run(REQUEST *request) return frame->result; } break; - } while (!frame->top_frame); + } /* * Nothing in this section, use the top frame result.