]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check for an attempt to pop the top frame and deal with that explicitly by breaking...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Nov 2017 14:49:04 +0000 (14:49 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Nov 2017 14:49:04 +0000 (14:49 +0000)
This allows the function to return at the right point without decrementing stack->depth

src/main/unlang_interpret.c

index e560ae1224ded26326e89d8e72b4e2fd20f4d3fa..6aee2c004f0682490cc8a483f27a00622cae9a9b 100644 (file)
@@ -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.