Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Lindgren <john.lindgren@tds.net>
To: alsa-devel@alsa-project.org
Subject: [PATCH] Memory leak in namehint.c
Date: Tue, 20 Jul 2010 15:26:32 -0400	[thread overview]
Message-ID: <4C45F868.7060807@tds.net> (raw)

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;

             reply	other threads:[~2010-07-20 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 19:26 John Lindgren [this message]
2010-07-20 22:38 ` [PATCH] Memory leak in namehint.c John Lindgren
2010-07-21  7:28   ` Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C45F868.7060807@tds.net \
    --to=john.lindgren@tds.net \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox