From: Sören Tempel Date: Sun, 6 Jun 2021 01:14:19 +0000 (+0200) Subject: alsactl: load_state: Only delete config if one was loaded X-Git-Tag: v1.2.5.1~5 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=6018c2014ac24877b2aa58c2c57f2fd901e6c7b1;p=alsa-utils.git 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 Signed-off-by: Jaroslav Kysela --- diff --git a/alsactl/state.c b/alsactl/state.c index 439e1f8..adbd13f 100644 --- a/alsactl/state.c +++ b/alsactl/state.c @@ -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; }