]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: use a copy of the command line defines
authorJaroslav Kysela <perex@perex.cz>
Fri, 28 Jan 2022 17:53:39 +0000 (18:53 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 28 Jan 2022 17:53:52 +0000 (18:53 +0100)
Fixes: a9b3525 ("topology: don't fail when Define section is missing in the included file")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/pre-processor.c

index f32f80c74ba9383a0af9abd7b1952cb4b7d981c1..3a227e386530d8ca3f2c0b3917f222d1e0a2b2d8 100644 (file)
@@ -249,7 +249,7 @@ static int pre_process_set_defines(struct tplg_pre_processor *tplg_pp, const cha
 
 static int pre_process_add_defines(struct tplg_pre_processor *tplg_pp, snd_config_t *from)
 {
-       snd_config_t *conf_defines;
+       snd_config_t *conf_defines, *conf_tmp;
        int ret;
 
        ret = snd_config_search(from, "Define", &conf_defines);
@@ -280,16 +280,6 @@ create:
                        return ret;
        }
 
-       /*
-        * merge the command line defines with the variables in the conf file to override
-        * default values
-        */
-       ret = snd_config_merge(conf_defines, tplg_pp->define_cfg, true);
-       if (ret < 0) {
-               fprintf(stderr, "Failed to override variable definitions\n");
-               return ret;
-       }
-
        if (tplg_pp->define_cfg_merged != conf_defines) {
                /*
                 * merge back to the main configuration tree (Define subtree)
@@ -301,6 +291,22 @@ create:
                }
        }
 
+       /*
+        * merge the command line defines with the variables in the conf file to override
+        * default values; use a copy (merge deletes the source tree)
+        */
+       ret = snd_config_copy(&conf_tmp, tplg_pp->define_cfg);
+       if (ret < 0) {
+               fprintf(stderr, "Failed to copy variable definitions\n");
+               return ret;
+       }
+       ret = snd_config_merge(tplg_pp->define_cfg_merged, conf_tmp, true);
+       if (ret < 0) {
+               fprintf(stderr, "Failed to override variable definitions\n");
+               snd_config_delete(conf_tmp);
+               return ret;
+       }
+
        return 0;
 }