2014-03-05 14:02:30

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH] android/avdtp: Fix crash when DISCOVER failed

Discover callback is only set when avdtp_discover was successful so we
need to check if it's set before calling.
---
android/avdtp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/avdtp.c b/android/avdtp.c
index f104e3e..96c7d0d 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -937,7 +937,8 @@ static void finalize_discovery(struct avdtp *session, int err)
if (discover->id > 0)
g_source_remove(discover->id);

- discover->cb(session, session->seps, err ? &avdtp_err : NULL,
+ if (discover->cb)
+ discover->cb(session, session->seps, err ? &avdtp_err : NULL,
discover->user_data);
g_free(discover);
}
--
1.8.5.4



2014-03-05 15:46:04

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH] android/avdtp: Fix crash when DISCOVER failed

Hi Andrzej,

On Wednesday 05 of March 2014 15:02:30 Andrzej Kaczmarek wrote:
> Discover callback is only set when avdtp_discover was successful so we
> need to check if it's set before calling.
> ---
> android/avdtp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/android/avdtp.c b/android/avdtp.c
> index f104e3e..96c7d0d 100644
> --- a/android/avdtp.c
> +++ b/android/avdtp.c
> @@ -937,7 +937,8 @@ static void finalize_discovery(struct avdtp *session, int err)
> if (discover->id > 0)
> g_source_remove(discover->id);
>
> - discover->cb(session, session->seps, err ? &avdtp_err : NULL,
> + if (discover->cb)
> + discover->cb(session, session->seps, err ? &avdtp_err : NULL,
> discover->user_data);
> g_free(discover);
> }
>

Applied.

--
Best regards,
Szymon Janc