alsactl: load_state: Only delete config if one was loaded

If load_configuration fails with open_failed == true, load_state will
jump to the out label without config being initialized and pass this
uninitialized config value to snd_config_delete. This commit fixes this
issue by initializing config with NULL and checking if it is non-null
before invoking snd_config_delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/94
Fixes: f138117 ("alsactl: load_state() - initialize config variable for the open_failed case")
BugLink: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Sören Tempel 2021-06-06 03:14:19 +02:00 committed by Jaroslav Kysela
parent f138117a45
commit 6018c2014a

View file

@ -1692,7 +1692,8 @@ int load_state(const char *cfgdir, const char *file,
}
err = finalerr ? finalerr : snd_card_iterator_error(&iter);
out:
snd_config_delete(config);
if (config)
snd_config_delete(config);
snd_config_update_free_global();
return err;
}