OSDN Git Service

Fix possible null-pointer de-reference in bta_gattc_util
authorAndre Eisenbach <eisenbach@google.com>
Sat, 27 Jun 2015 05:30:33 +0000 (22:30 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Sun, 28 Jun 2015 17:12:13 +0000 (10:12 -0700)
Bug: 21756298
Change-Id: I4bd38f6fa594ccb4dd9f23f3887484743a3bc451

bta/gatt/bta_gattc_utils.c

index bffbc4c..c8648b9 100644 (file)
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "utl.h"
+
+#include "btcore/include/bdaddr.h"
+#include "btif/include/btif_util.h"
 #include "gki.h"
+#include "utl.h"
 #include "bta_sys.h"
 #include "bta_gattc_int.h"
 #include "l2c_api.h"
@@ -710,10 +713,12 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda
     }
     if (!add)
     {
-        uint8_t *bda = (uint8_t *)remote_bda_ptr;
-        APPL_TRACE_ERROR("%s unable to find the bg connection mask for"
-            " bd_addr:%02x:%02x:%02x:%02x:%02x:%02x", __func__,
-            bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
+        if (remote_bda_ptr)
+        {
+            bdstr_t bdstr = {0};
+            APPL_TRACE_ERROR("%s unable to find the bg connection mask for: %s", __func__,
+                bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
+        }
         return FALSE;
     }
     else /* adding a new device mask */