* [PATCH v2] audio: fix memory leak with typefinding
@ 2010-06-24 14:37 harri.mahonen
2010-06-24 14:54 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 2+ messages in thread
From: harri.mahonen @ 2010-06-24 14:37 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Harri Mahonen
From: Harri Mahonen <harri.mahonen@gmail.com>
Each time sbc_typefind is called and there is no syncword, sbc_finalize
never gets called. Instead of hardcoded syncword check, rely on
sbc_parse to do it properly.
Signed-off-by: Harri Mahonen <harri.mahonen@gmail.com>
---
audio/gstbluetooth.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/audio/gstbluetooth.c b/audio/gstbluetooth.c
index 26dd4a5..3bc0690 100644
--- a/audio/gstbluetooth.c
+++ b/audio/gstbluetooth.c
@@ -50,21 +50,25 @@ 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)
return;
- if (data == NULL || *data != 0x9c) /* SBC syncword */
+ if (sbc_init(&sbc, 0) < 0)
return;
aux = g_new(guint8, 32);
memcpy(aux, data, 32);
- sbc_parse(&sbc, aux, 32);
- g_free(aux);
- caps = gst_sbc_parse_caps_from_sbc(&sbc);
- sbc_finish(&sbc);
+ if (sbc_parse(&sbc, aux, 32) < 0)
+ goto done;
+
+ caps = gst_sbc_parse_caps_from_sbc(&sbc);
gst_type_find_suggest(tf, GST_TYPE_FIND_POSSIBLE, caps);
gst_caps_unref(caps);
+
+done:
+ g_free(aux);
+ sbc_finish(&sbc);
}
static gchar *sbc_exts[] = { "sbc", NULL };
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] audio: fix memory leak with typefinding
2010-06-24 14:37 [PATCH v2] audio: fix memory leak with typefinding harri.mahonen
@ 2010-06-24 14:54 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2010-06-24 14:54 UTC (permalink / raw)
To: harri.mahonen; +Cc: linux-bluetooth
Hi,
On Thu, Jun 24, 2010 at 5:37 PM, <harri.mahonen@gmail.com> wrote:
> From: Harri Mahonen <harri.mahonen@gmail.com>
>
> Each time sbc_typefind is called and there is no syncword, sbc_finalize
> never gets called. Instead of hardcoded syncword check, rely on
> sbc_parse to do it properly.
>
> Signed-off-by: Harri Mahonen <harri.mahonen@gmail.com>
> ---
> audio/gstbluetooth.c | 16 ++++++++++------
> 1 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/audio/gstbluetooth.c b/audio/gstbluetooth.c
> index 26dd4a5..3bc0690 100644
> --- a/audio/gstbluetooth.c
> +++ b/audio/gstbluetooth.c
> @@ -50,21 +50,25 @@ 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)
> return;
>
> - if (data == NULL || *data != 0x9c) /* SBC syncword */
> + if (sbc_init(&sbc, 0) < 0)
> return;
>
> aux = g_new(guint8, 32);
> memcpy(aux, data, 32);
> - sbc_parse(&sbc, aux, 32);
> - g_free(aux);
> - caps = gst_sbc_parse_caps_from_sbc(&sbc);
> - sbc_finish(&sbc);
>
> + if (sbc_parse(&sbc, aux, 32) < 0)
> + goto done;
> +
> + caps = gst_sbc_parse_caps_from_sbc(&sbc);
> gst_type_find_suggest(tf, GST_TYPE_FIND_POSSIBLE, caps);
> gst_caps_unref(caps);
> +
> +done:
> + g_free(aux);
> + sbc_finish(&sbc);
> }
>
> static gchar *sbc_exts[] = { "sbc", NULL };
Looks great, but we don't use the signed-off-by thing.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-24 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-24 14:37 [PATCH v2] audio: fix memory leak with typefinding harri.mahonen
2010-06-24 14:54 ` Luiz Augusto von Dentz
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).