topology: pre-processor: fix seg fault when there no command line defines

In case there are not command line definitions, there is nothing to
merge or delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/141
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Ranjani Sridharan 2022-01-28 13:36:03 -08:00 committed by Jaroslav Kysela
parent b5748d329b
commit ed36ce25a7

View file

@ -172,6 +172,7 @@ void free_pre_processor(struct tplg_pre_processor *tplg_pp)
snd_output_close(tplg_pp->output);
snd_output_close(tplg_pp->dbg_output);
snd_config_delete(tplg_pp->output_cfg);
if (tplg_pp->define_cfg)
snd_config_delete(tplg_pp->define_cfg);
free(tplg_pp->inc_path);
free(tplg_pp);
@ -295,6 +296,7 @@ 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)
*/
if (tplg_pp->define_cfg) {
ret = snd_config_copy(&conf_tmp, tplg_pp->define_cfg);
if (ret < 0) {
fprintf(stderr, "Failed to copy variable definitions\n");
@ -306,6 +308,7 @@ create:
snd_config_delete(conf_tmp);
return ret;
}
}
return 0;
}