* [PATCH] Memory leak in namehint.c
@ 2010-07-20 19:26 John Lindgren
2010-07-20 22:38 ` John Lindgren
0 siblings, 1 reply; 3+ messages in thread
From: John Lindgren @ 2010-07-20 19:26 UTC (permalink / raw)
To: alsa-devel
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 <john.lindgren@tds.net>
---
src/control/namehint.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/control/namehint.c b/src/control/namehint.c
index 78572d8..fc1cb27 100644
--- a/src/control/namehint.c
+++ b/src/control/namehint.c
@@ -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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Memory leak in namehint.c
2010-07-20 19:26 [PATCH] Memory leak in namehint.c John Lindgren
@ 2010-07-20 22:38 ` John Lindgren
2010-07-21 7:28 ` Jaroslav Kysela
0 siblings, 1 reply; 3+ messages in thread
From: John Lindgren @ 2010-07-20 22:38 UTC (permalink / raw)
To: alsa-devel
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 <john.lindgren@tds.net>
---
src/control/namehint.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/control/namehint.c b/src/control/namehint.c
index 78572d8..1819292 100644
--- a/src/control/namehint.c
+++ b/src/control/namehint.c
@@ -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;
On 07/20/2010 03:26 PM, John Lindgren wrote:
> 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 <john.lindgren@tds.net>
> ---
>
> src/control/namehint.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/src/control/namehint.c b/src/control/namehint.c
> index 78572d8..fc1cb27 100644
> --- a/src/control/namehint.c
> +++ b/src/control/namehint.c
> @@ -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;
>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Memory leak in namehint.c
2010-07-20 22:38 ` John Lindgren
@ 2010-07-21 7:28 ` Jaroslav Kysela
0 siblings, 0 replies; 3+ messages in thread
From: Jaroslav Kysela @ 2010-07-21 7:28 UTC (permalink / raw)
To: John Lindgren; +Cc: alsa-devel
On Tue, 20 Jul 2010, John Lindgren wrote:
> 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.
Applied. Thanks.
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-21 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 19:26 [PATCH] Memory leak in namehint.c John Lindgren
2010-07-20 22:38 ` John Lindgren
2010-07-21 7:28 ` Jaroslav Kysela
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.