[alsa-devel] [PATCH lib 3/5] namehint: Fix bad free with invalid iface name

Takashi Iwai tiwai at suse.de
Thu Apr 30 15:06:16 CEST 2015


Due to the uninitialized field before the error path, passing an
invalid iface argument may result in a bad free() call.  Initialize
the fields properly beforehand.

Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
 src/control/namehint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/control/namehint.c b/src/control/namehint.c
index 6c04143a185c..b3e646eb10af 100644
--- a/src/control/namehint.c
+++ b/src/control/namehint.c
@@ -562,6 +562,8 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
 	list.list = NULL;
 	list.count = list.allocated = 0;
 	list.siface = iface;
+	list.show_all = 0;
+	list.cardname = NULL;
 	if (strcmp(iface, "card") == 0)
 		list.iface = SND_CTL_ELEM_IFACE_CARD;
 	else if (strcmp(iface, "pcm") == 0)
@@ -581,8 +583,6 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
 		goto __error;
 	}
 
-	list.show_all = 0;
-	list.cardname = NULL;
 	if (snd_config_search(local_config, "defaults.namehint.showall", &conf) >= 0)
 		list.show_all = snd_config_get_bool(conf) > 0;
 	if (card >= 0) {
-- 
2.3.6



More information about the Alsa-devel mailing list