unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
- switch (frame->instruction->type) {
- case UNLANG_TYPE_MODULE:
- case UNLANG_TYPE_FUNCTION:
- case UNLANG_TYPE_REDUNDANT:
- case UNLANG_TYPE_LOAD_BALANCE:
- case UNLANG_TYPE_REDUNDANT_LOAD_BALANCE:
- case UNLANG_TYPE_PARALLEL:
- case UNLANG_TYPE_IF:
- case UNLANG_TYPE_FILTER:
- case UNLANG_TYPE_UPDATE:
- case UNLANG_TYPE_SWITCH:
- case UNLANG_TYPE_FOREACH:
- case UNLANG_TYPE_MAP:
- case UNLANG_TYPE_SUBREQUEST:
- case UNLANG_TYPE_CALL:
- case UNLANG_TYPE_EDIT:
- case UNLANG_TYPE_XLAT:
- case UNLANG_TYPE_TMPL:
- return (TALLOC_CTX *) frame->state;
-
- case UNLANG_TYPE_GROUP:
- case UNLANG_TYPE_ELSE:
- case UNLANG_TYPE_ELSIF:
- case UNLANG_TYPE_CASE:
- case UNLANG_TYPE_BREAK:
- case UNLANG_TYPE_RETURN:
- case UNLANG_TYPE_DETACH:
- case UNLANG_TYPE_CALLER:
- case UNLANG_TYPE_POLICY:
- break;
-
- case UNLANG_TYPE_NULL:
- case UNLANG_TYPE_MAX:
- fr_assert(0);
- break;
- }
+ if (frame->state) return (TALLOC_CTX *)frame->state;
/*
- * Ensure that the memory is always cleaned up when the
- * request exits. And make sure that this function is safe to call from anywhere.
+ * If the frame doesn't ordinarily have a
+ * state, assume the caller knows what it's
+ * doing and allocate one.
*/
- return (TALLOC_CTX *)request;
+ return (TALLOC_CTX *)frame->state = talloc_new(request);
}
static xlat_arg_parser_t const unlang_interpret_xlat_args[] = {