Memory leak in namehint.c
PATCH 1/1 Memory leak in namehint.c
get_card_name() can be called more than once on the same list, so it must free the previous list->cardname before replacing it.
Signed-off-by John Lindgren <[email protected]>
---
src/control/namehint.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
src/control/namehint.c +2 -0
@@ -471,6 +471,8 @@ static int get_card_name(struct hint_list *list, int card)char scard[16 ], *s;int err; +if (list->cardname) +free (list->cardname); err =snd_card_get_name (card, &list->cardname);if (err <=0 )return 0 ;
Please disregard the previous patch as it has the potential for a double free() if snd_card_get_name() fails. Here is a corrected patch.
Signed-off-by John Lindgren <[email protected]>
---
src/control/namehint.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
src/control/namehint.c +2 -0
@@ -471,6 +471,8 @@ static int get_card_name(struct hint_list *list, int card)char scard[16 ], *s;int err; +free (list->cardname); + list->cardname =NULL ; err =snd_card_get_name (card, &list->cardname);if (err <=0 )return 0 ;
Quoted 23 lines · John Lindgren
get_card_name()can be called more than once on the same list, so it must free the previouslist->cardnamebefore replacing it.Signed-off-by John Lindgren <[email protected]>---
src/control/namehint.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)src/control/namehint.c +2
-0@@ -471,6 +471,8 @@ static int get_card_name(struct hint_list *list, int card)char scard[16 ], *s;int err; +if (list->cardname) +free (list->cardname); err =snd_card_get_name (card, &list->cardname);if (err <=0 )return 0 ;
Jaroslav Kysela
AppliedQuoted 2 lines · John Lindgren
Please disregard the previous patch as it has the potential for a double
free()ifsnd_card_get_name()fails. Here is a corrected patch.
Applied. Thanks.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.