} modcall_stack;
+static void pairfree_wrapper(void *data)
+{
+ VALUE_PAIR **vp = (VALUE_PAIR **) data;
+ pairfree(vp);
+}
+
/*
* Call a module, iteratively, with a local stack, rather than
* recursively. What did Paul Graham say about Lisp...?
modgroup *g = mod_callabletogroup(child);
for (i = 0; i < 8; i++) {
- if (!request_data_get(request, radius_get_vp, i)) {
+ if (!request_data_reference(request,
+ radius_get_vp, i)) {
depth = i;
break;
}
stack.pointer + 1, modcall_spaces,
child->name);
while (vp) {
+ VALUE_PAIR *copy = NULL, **copy_p;
+
#ifndef NDEBUG
if (fr_debug_flag >= 2) {
char buffer[1024];
}
#endif
+ copy = paircopy(vp);
+ copy_p = ©
+
request_data_add(request, radius_get_vp,
- depth, vp, NULL);
+ depth, copy_p,
+ pairfree_wrapper);
myresult = modcall(component,
g->children,
vp = pairfind(vp->next,
vp->attribute,
vp->vendor);
- }
- /*
- * Delete the cached attribute.
- */
- request_data_get(request, radius_get_vp, depth);
- }
+ /*
+ * Delete the cached attribute,
+ * if it exists.
+ */
+ if (copy) {
+ request_data_get(request,
+ radius_get_vp,
+ depth);
+ pairfree(©);
+ } else {
+ break;
+ }
+ } /* loop over VPs */
+ } /* if the VP exists */
myresult = RLM_MODULE_OK;
goto handle_result;
* Dynamically translate for check:, request:, reply:, etc.
*/
static size_t xlat_foreach(void *instance, REQUEST *request,
- char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ UNUSED char *fmt, char *out, size_t outlen,
+ RADIUS_ESCAPE_STRING func)
{
- VALUE_PAIR *vp;
+ VALUE_PAIR **pvp;
/*
* See modcall, "FOREACH" for how this works.
*/
- vp = request_data_reference(request, radius_get_vp, *(int*) instance);
- if (!vp) {
+ pvp = (VALUE_PAIR **) request_data_reference(request, radius_get_vp,
+ *(int*) instance);
+ if (!pvp || !*pvp) {
*out = '\0';
return 0;
}
- return valuepair2str(out, outlen, vp, vp->type, func);
+ return valuepair2str(out, outlen, (*pvp), (*pvp)->type, func);
}
#endif