Skip to content

Commit 1f73b44

Browse files
committed
use intermediate variables while talking the tree
instead of using the input variables, which then get over-written
1 parent fdc6295 commit 1f73b44

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/lib/server/cf_util.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ fr_token_t cf_section_name2_quote(CONF_SECTION const *cs)
12461246
*/
12471247
fr_token_t cf_section_argv_quote(CONF_SECTION const *cs, int argc)
12481248
{
1249-
if (!cs || !cs->argv_quote || (argc < 0) || (argc > cs->argc)) return T_INVALID;
1249+
if (!cs || !cs->argv_quote || (argc < 0) || (argc >= cs->argc)) return T_INVALID;
12501250

12511251
return cs->argv_quote[argc];
12521252
}
@@ -1877,20 +1877,24 @@ void *_cf_data_remove(CONF_ITEM *parent, CONF_DATA const *cd)
18771877
int _cf_data_walk(CONF_ITEM *ci, char const *type, cf_walker_t cb, void *ctx)
18781878
{
18791879
CONF_DATA *cd;
1880+
CONF_ITEM *item;
1881+
fr_rb_tree_t *tree;
18801882
fr_rb_iter_inorder_t iter;
18811883
int ret = 0;
18821884

18831885
if (!ci->ident2) return 0;
18841886

1885-
for (ci = fr_rb_iter_init_inorder(ci->ident2, &iter);
1886-
ci;
1887-
ci = fr_rb_iter_next_inorder(ci->ident2, &iter)) {
1887+
tree = ci->ident2;
1888+
1889+
for (item = fr_rb_iter_init_inorder(tree, &iter);
1890+
item;
1891+
item = fr_rb_iter_next_inorder(tree, &iter)) {
18881892
/*
18891893
* We're walking ident2, not all of the items will be data
18901894
*/
1891-
if (ci->type != CONF_ITEM_DATA) continue;
1895+
if (item->type != CONF_ITEM_DATA) continue;
18921896

1893-
cd = (void *) ci;
1897+
cd = (void *) item;
18941898
if ((cd->type != type) && (strcmp(cd->type, type) != 0)) continue;
18951899

18961900
ret = cb(UNCONST(void *, cd->data), ctx);

0 commit comments

Comments
 (0)