summaryrefslogtreecommitdiff
path: root/android/main.c
diff options
context:
space:
mode:
authorMarcin Kraglak <marcin.kraglak@tieto.com>2014-03-31 14:45:13 +0200
committerSzymon Janc <szymon.janc@tieto.com>2014-03-31 15:53:31 +0200
commitf87ad9690fd42b3cc9aa1f5a36e04becfc326348 (patch)
treeab18b8b927f1104794ed36207e1ee7e6cbd923f7 /android/main.c
parenta7191058a08f7e1d08e8b6757b4ed4c0127a9eb5 (diff)
downloadbluez-f87ad9690fd42b3cc9aa1f5a36e04becfc326348.tar.gz
android: Fix NULL pointer dereference
If there is no adapter, hal_ipc in not initialized. Below is message from valgrind: ==22501== Invalid read of size 4 ==22501== at 0x805B809: ipc_unregister (ipc.c:421) ==22501== by 0x804AEAF: main (main.c:548) ==22501== Address 0x4 is not stack'd, malloc'd or (recently) free'd
Diffstat (limited to 'android/main.c')
-rw-r--r--android/main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/android/main.c b/android/main.c
index 828f81db1..e229a6db4 100644
--- a/android/main.c
+++ b/android/main.c
@@ -541,8 +541,11 @@ int main(int argc, char *argv[])
bt_bluetooth_cleanup();
g_main_loop_unref(event_loop);
- ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
- ipc_cleanup(hal_ipc);
+ /* If no adapter was initialized, hal_ipc is NULL */
+ if (hal_ipc) {
+ ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
+ ipc_cleanup(hal_ipc);
+ }
info("Exit");