]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check variable before dereferencing it. Found by PVS-Studio
authorAlan T. DeKok <aland@freeradius.org>
Thu, 19 Dec 2019 14:23:01 +0000 (09:23 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 19 Dec 2019 14:23:01 +0000 (09:23 -0500)
src/lib/unlang/foreach.c

index 710592ac79593053cf3e944210a4312328d1048e..6cd46a4867a24c321fc95031e4bb0633e4270a0f 100644 (file)
@@ -123,7 +123,7 @@ static unlang_action_t unlang_foreach_next(REQUEST *request, rlm_rcode_t *presul
 static unlang_action_t unlang_foreach(REQUEST *request, rlm_rcode_t *presult)
 {
        unlang_stack_t                  *stack = request->stack;
-       unlang_stack_frame_t            *frame = &stack->frame[stack->depth];
+       unlang_stack_frame_t            *frame;
        unlang_t                        *instruction = frame->instruction;
        unlang_frame_state_foreach_t    *foreach = NULL;
        unlang_group_t                  *g;
@@ -132,16 +132,18 @@ static unlang_action_t unlang_foreach(REQUEST *request, rlm_rcode_t *presult)
 
        g = unlang_generic_to_group(instruction);
 
-       /*
-        *      Ensure any breaks terminate here...
-        */
-       break_point_set(frame);
-
        if (stack->depth >= UNLANG_STACK_MAX) {
                ERROR("Internal sanity check failed: module stack is too deep");
                fr_exit(EXIT_FAILURE);
        }
 
+       frame = &stack->frame[stack->depth];
+
+       /*
+        *      Ensure any breaks terminate here...
+        */
+       break_point_set(frame);
+
        /*
         *      Figure out foreach depth by walking back up the stack
         */