From 23a191a82c693456e61431ab699cddc1e5782a26 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 29 Jun 2021 19:31:28 +0200 Subject: [PATCH] control: remap - assign right name to the child handle for no-op (2nd case) Fixes: https://github.com/alsa-project/alsa-utils/issues/100 Signed-off-by: Jaroslav Kysela --- src/control/control_remap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/control/control_remap.c b/src/control/control_remap.c index 81524014..4914f960 100644 --- a/src/control/control_remap.c +++ b/src/control/control_remap.c @@ -1154,6 +1154,10 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema snd_ctl_t *ctl; int result, err; + /* no-op, remove the plugin */ + if (!remap && !map) + goto _noop; + priv = calloc(1, sizeof(*priv)); if (priv == NULL) return -ENOMEM; @@ -1173,6 +1177,7 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema /* no-op check, remove the plugin */ if (priv->map_items == 0 && priv->remap_items == 0) { remap_free(priv); + _noop: free(child->name); child->name = name ? strdup(name) : NULL; if (name && !child->name) @@ -1316,11 +1321,6 @@ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd err = _snd_ctl_open_child(&cctl, root, child, mode, conf); if (err < 0) return err; - /* no-op, remove the plugin */ - if (!remap && !map) { - *handlep = cctl; - return 0; - } err = snd_ctl_remap_open(handlep, name, remap, map, cctl, mode); if (err < 0) snd_ctl_close(cctl); -- 2.47.1