]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: load_state: Only delete config if one was loaded
authorSören Tempel <soeren+git@soeren-tempel.net>
Sun, 6 Jun 2021 01:14:19 +0000 (03:14 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 7 Jun 2021 17:06:19 +0000 (19:06 +0200)
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>
alsactl/state.c

index 439e1f8e07ddac0a6ccd437da769615502bbe8d4..adbd13f97434781320f3a44f993b9fac3a0e00eb 100644 (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;
 }