From: Arran Cudbard-Bell Date: Tue, 12 Nov 2024 15:51:29 +0000 (-0600) Subject: Explicitly pre-alloc numbers for defines X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f199cf3a04b5ba9060192b1934f3c618aca003d;p=thirdparty%2Ffreeradius-server.git Explicitly pre-alloc numbers for defines --- diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 7d02fe7016f..08ce533fcae 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -1106,12 +1106,6 @@ static int dict_read_process_define(dict_tokenize_ctx_t *ctx, char **argv, int a */ memcpy(&da->flags, base_flags, sizeof(da->flags)); - /* - * Since there is no number, the attribute cannot be - * encoded as a number. - */ - da->flags.name_only = true; - /* * Set the base type of the attribute. */ @@ -1165,8 +1159,19 @@ static int dict_read_process_define(dict_tokenize_ctx_t *ctx, char **argv, int a if (!ctx->dict) goto error; #endif + /* + * Since there is no number, the attribute cannot be + * encoded as a number. + */ + da->flags.name_only = true; + if (unlikely(dict_attr_parent_init(&da, parent) < 0)) goto error; + /* + * Add an attribute number now so the allocations occur in order + */ + if (unlikely(dict_attr_num_init_name_only(da) < 0)) goto error; + /* * Set the attribute name */