Don't go to next sibling on empty case. Fixes #1274
authorAlan T. DeKok <aland@freeradius.org>
Mon, 28 Sep 2015 13:29:13 +0000 (09:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 28 Sep 2015 13:29:13 +0000 (09:29 -0400)
src/main/modcall.c
src/tests/keywords/case-empty [new file with mode: 0644]

index d02b003..00324d6 100644 (file)
@@ -772,6 +772,11 @@ redo:
                 *      MOD_GROUP.
                 */
                if (!g->children) {
+                       if (c->type == MOD_CASE) {
+                               result = RLM_MODULE_NOOP;
+                               goto calculate_result;
+                       }
+
                        RDEBUG2("%s { ... } # empty sub-section is ignored", c->name);
                        goto next_sibling;
                }
diff --git a/src/tests/keywords/case-empty b/src/tests/keywords/case-empty
new file mode 100644 (file)
index 0000000..46ea054
--- /dev/null
@@ -0,0 +1,23 @@
+# PRE: switch
+#
+update reply {
+       Filter-Id := "filter"
+}
+
+switch &reply:Filter-Id {
+       # deliberately empty
+       case "filter" {
+       }
+
+       case "fail" {
+               update reply {
+                       Filter-Id := "fail"
+               }
+       }
+
+       case {
+               update reply {
+                       Filter-Id := "default"
+               }
+       }
+}