From 4b21e1aa7621206ed7a4a83ad8f375c848bb72fa Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 23 Jul 2014 14:34:59 +0300 Subject: [PATCH] android/client: Fix crash reading not connected SCO When SCO is not connected we get -1 from in_read() HAL function. --- android/client/if-sco.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/client/if-sco.c b/android/client/if-sco.c index 70e273755..c33b012a9 100644 --- a/android/client/if-sco.c +++ b/android/client/if-sco.c @@ -287,7 +287,7 @@ static void *read_thread(void *data) { int (*filbuff_cb) (short*, void*) = feed_from_in; short buffer[buffer_size_in / sizeof(short)]; - size_t len = 0; + ssize_t len = 0; void *cb_data = NULL; FILE *out = data; @@ -311,6 +311,10 @@ static void *read_thread(void *data) pthread_mutex_unlock(&state_mutex); len = filbuff_cb(buffer, cb_data); + if (len < 0) { + haltest_error("Error receiving SCO data"); + break; + } haltest_info("Read %zd bytes\n", len); -- 2.47.3