linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: harri.mahonen@gmail.com
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] audio: fix memory leak with typefinding
Date: Thu, 24 Jun 2010 10:52:47 +0300	[thread overview]
Message-ID: <AANLkTikqyXXpC0guYSAZb4L-V6Cg5A_L6MJdcc5ChRpJ@mail.gmail.com> (raw)
In-Reply-To: <1277320206-6969-1-git-send-email-harri.mahonen@gmail.com>

Hi,

On Wed, Jun 23, 2010 at 10:10 PM,  <harri.mahonen@gmail.com> wrote:
> From: Harri Mahonen <harri.mahonen@gmail.com>
>
> sbc structure gets leaked each time when there is no data or SBC
> syncword, because sbc_finalize is not called. Call sbc_init after
> checking the data for syncword.
>
> Signed-off-by: Harri Mahonen <harri.mahonen@gmail.com>
> ---
>  audio/gstbluetooth.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/audio/gstbluetooth.c b/audio/gstbluetooth.c
> index 26dd4a5..11aefd7 100644
> --- a/audio/gstbluetooth.c
> +++ b/audio/gstbluetooth.c
> @@ -50,10 +50,10 @@ static void sbc_typefind(GstTypeFind *tf, gpointer ignore)
>        sbc_t sbc;
>        guint8 *data = gst_type_find_peek(tf, 0, 32);
>
> -       if (sbc_init(&sbc, 0) < 0)
> +       if (data == NULL || *data != 0x9c)      /* SBC syncword */
>                return;
>
> -       if (data == NULL || *data != 0x9c)      /* SBC syncword */
> +       if (sbc_init(&sbc, 0) < 0)
>                return;
>
>        aux = g_new(guint8, 32);

We might want to have this fix inside sbc_init instead since others
projects like pulseaudio may run into the same problem, also I guess
it is a good practice to free any data allocated when returning an
error.


-- 
Luiz Augusto von Dentz
Computer Engineer

  reply	other threads:[~2010-06-24  7:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 19:10 [PATCH] audio: fix memory leak with typefinding harri.mahonen
2010-06-24  7:52 ` Luiz Augusto von Dentz [this message]
2010-06-24  8:09   ` Luiz Augusto von Dentz
2010-06-24 14:36     ` Harri Mähönen

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=AANLkTikqyXXpC0guYSAZb4L-V6Cg5A_L6MJdcc5ChRpJ@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=harri.mahonen@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).