OSDN Git Service

Adds null check before freeing LE services list
authorSubramanian Srinivasan <subrsrin@codeaurora.org>
Fri, 15 Jan 2016 01:45:01 +0000 (17:45 -0800)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 28 Jan 2016 15:11:05 +0000 (15:11 +0000)
Prevents the crash which happens when device is
disconnected during service discovery and the
services list is not yet properly allocated
memory and populated. This change frees up the
services list after discovery complete only when
it is not null.

Change-Id: I0ced14d2ee133a332fa2fd7c456267438813a600

bta/gatt/bta_gattc_act.c

index 691e2c9..a9b9cd1 100644 (file)
@@ -1049,8 +1049,11 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
         /* used to reset cache in application */
         bta_gattc_co_cache_reset(p_clcb->p_srcb->server_bda);
     }
-    /* release pending attribute list buffer */
-    utl_freebuf((void **)&p_clcb->p_srcb->p_srvc_list);
+    if(p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list)
+    {
+        /* release pending attribute list buffer */
+        utl_freebuf((void **)&p_clcb->p_srcb->p_srvc_list);
+    }
 
     if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING)
     {