]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Explicitly pre-alloc numbers for defines
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Nov 2024 15:51:29 +0000 (09:51 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Nov 2024 20:25:39 +0000 (14:25 -0600)
src/lib/util/dict_tokenize.c

index 7d02fe7016f7c3fae4adc134f3e1de88fd3b9756..08ce533fcaefe9d847a28a36fdffa4540058dba0 100644 (file)
@@ -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
         */