]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move to new syntax
authorAlan T. DeKok <aland@freeradius.org>
Tue, 18 Mar 2025 09:31:47 +0000 (16:31 +0700)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 18 Mar 2025 14:25:12 +0000 (21:25 +0700)
and fix crash on nothing to loop over

src/lib/unlang/foreach.c
src/tests/keywords/foreach-break

index ae1abd172f1c138f3a209e97cb6fb630feeca3db..4dd56b1b916a97737f4aaf698698a41093317963 100644 (file)
@@ -163,8 +163,7 @@ static int _free_unlang_frame_state_foreach(unlang_frame_state_foreach_t *state)
                 *      Now that we're done, the leaf entries can be changed again.
                 */
                vp = tmpl_dcursor_init(NULL, NULL, &state->cc, &state->cursor, state->request, state->vpt);
-               fr_assert(vp != NULL);
-
+               if (!vp) return 0;
                do {
                        vp->vp_edit = false;
                } while ((vp = fr_dcursor_next(&state->cursor)) != NULL);
index 268430f3253c67d9bc9812f3d41d0bc6bd38161e..fb01aad89fcedb1c86022e818d37c82f083f0637 100644 (file)
@@ -8,17 +8,17 @@ request += {
        Filter-Id = "broken"
 }
 
-foreach Filter-Id {
+foreach thing (Filter-Id) {
        #
        #  If we see this one, "break" out of the
        #  foreach loop.
        #
-       if ("%{Foreach-Variable-0}" == "broken") {
+       if (thing == "broken") {
                break
        }
 
        reply += {
-               Called-Station-Id = "%{Foreach-Variable-0}"
+               Called-Station-Id = thing
        }
 }
 
@@ -31,8 +31,8 @@ request += {
        Filter-Id = "2"
 }
 
-foreach Reply-Message {
-       if ("%{Foreach-Variable-0}" == "1") {
+foreach thing (Reply-Message) {
+       if (thing == "1") {
                request += {
                        Filter-Id = "3"
                }
@@ -51,14 +51,14 @@ request += {
        Filter-Id = "2"
 }
 
-foreach Reply-Message {
-       if ("%{Foreach-Variable-0}" == "1") {
+foreach thing (Reply-Message) {
+       if (thing == "1") {
                request += {
                        Filter-Id = "3"
                }
        }
 
-       if ("%{Foreach-Variable-0}" == "3") {
+       if (thing == "3") {
                break
        }
 }