From 6018c2014ac24877b2aa58c2c57f2fd901e6c7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Sun, 6 Jun 2021 03:14:19 +0200 Subject: [PATCH] alsactl: load_state: Only delete config if one was loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- alsactl/state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; }