]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
ensure talloc parenting is OK
authorAlan T. DeKok <aland@freeradius.org>
Thu, 21 Dec 2023 17:46:55 +0000 (12:46 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 21 Dec 2023 18:44:33 +0000 (13:44 -0500)
src/lib/server/map.c

index dca323aec15a8f24c0343894fa0a7c9175320f3d..0c4990de9a5541cd7ac8506b1acb9c6605675139 100644 (file)
@@ -434,7 +434,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
        }
 
        *out = NULL;
-       MEM(map = map_alloc(ctx, parent));
+       MEM(map = map_alloc(ctx, NULL));
 
        (void)fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt);
 
@@ -757,10 +757,13 @@ parse_rhs:
 check_for_child:
 #endif
        /*
-        *      Add this map to to the parents list.  Note that the
-        *      caller will have to check for this!
+        *      Add this map to to the parents list.  Note that the caller
+        *      will have to check for this, but checking if map->parent
+        *      exists.
         */
        if (is_child && parent) {
+               (void) talloc_steal(parent, map);
+               map->parent = parent;
                map_list_insert_tail(&parent->child, map);
        }