Re: [PATCH] audio: fix memory leak with typefinding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, Jun 23, 2010 at 10:10 PM,  <harri.mahonen@xxxxxxxxx> wrote:
> From: Harri Mahonen <harri.mahonen@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux