fix a memory leakage when Queue search or discovery event.
bug:11562902
Change-Id: I16ba8cfb727d05e5d324c6301ba0ab23e729232b
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 40cfb9e..04bd186 100755
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -2037,6 +2037,10 @@
*******************************************************************************/
void bta_dm_queue_search (tBTA_DM_MSG *p_data)
{
+ if(bta_dm_search_cb.p_search_queue)
+ {
+ GKI_freebuf(bta_dm_search_cb.p_search_queue);
+ }
bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_SEARCH));
memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_SEARCH));
@@ -2054,6 +2058,10 @@
*******************************************************************************/
void bta_dm_queue_disc (tBTA_DM_MSG *p_data)
{
+ if(bta_dm_search_cb.p_search_queue)
+ {
+ GKI_freebuf(bta_dm_search_cb.p_search_queue);
+ }
bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER));
memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER));