fr_type_t type;
fr_dict_attr_flags_t flags;
char *ref = NULL;
+ fr_dict_attr_t const *da;
if ((argc < 2) || (argc > 3)) {
fr_strerror_const("Invalid MEMBER syntax");
int i;
for (i = 0; i <= ctx->stack[ctx->stack_depth].member_num; i++) {
- fr_dict_attr_t const *da;
-
da = dict_attr_child_by_num(ctx->stack[ctx->stack_depth].da, i);
if (!da) continue; /* really should be WTF? */
++ctx->stack[ctx->stack_depth].member_num,
type, &flags) < 0) return -1;
+ /*
+ * If we need to set the previous attribute, we have to
+ * look it up by number. This lets us set the
+ * *canonical* previous attribute, and not any potential
+ * duplicate which was just added.
+ */
+ da = dict_attr_child_by_num(ctx->stack[ctx->stack_depth].da, ctx->stack[ctx->stack_depth].member_num);
+ fr_assert(da != NULL);
+
/*
* A 'struct' can have a MEMBER of type 'tlv', but ONLY
* as the last entry in the 'struct'. If we see that,
if (ret < 0) return -1;
}
+ /*
+ * Adding a member of type 'struct' is an implicit BEGIN-STRUCT.
+ */
+ if (type == FR_TYPE_STRUCT) {
+ if (dict_gctx_push(ctx, da) < 0) return -1;
+ ctx->value_attr = NULL;
+ }
+
return 0;
}