BT App: Fix to resolve Static Code Analysis issues

Use case:
During static code analysis of Bluetooth Application
codespace, many NULL pointer exceptions
and Array Index Out of Bounds Exceptions were observed.

Root Cause:
No proper NULL checks before dereferencing a pointer
and no proper boundary checks kept for the array indices.

CRs-fixed: 1040047
Change-Id: I0c12a5ce37243695a839d0f976917da27d7fa989
3 files changed