From f97188d2d337ea129f2f27d918515a5cb90150b2 Mon Sep 17 00:00:00 2001 From: weitianhua Date: Wed, 8 Jul 2020 20:09:13 +0800 Subject: [PATCH] Add protection for rfcomm close API in SPP --- .../bt/host/bluedroid/stack/rfcomm/port_utils.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/bt/host/bluedroid/stack/rfcomm/port_utils.c b/components/bt/host/bluedroid/stack/rfcomm/port_utils.c index 0b08c0f1f3..fc3f281c9f 100644 --- a/components/bt/host/bluedroid/stack/rfcomm/port_utils.c +++ b/components/bt/host/bluedroid/stack/rfcomm/port_utils.c @@ -210,16 +210,18 @@ void port_release_port (tPORT *p_port) osi_mutex_global_lock(); RFCOMM_TRACE_DEBUG("port_release_port, p_port:%p", p_port); - while ((p_buf = (BT_HDR *)fixed_queue_dequeue(p_port->rx.queue, 0)) != NULL) { - osi_free (p_buf); + if (p_port->rx.queue) { + while ((p_buf = (BT_HDR *)fixed_queue_dequeue(p_port->rx.queue, 0)) != NULL) { + osi_free (p_buf); + } } - p_port->rx.queue_size = 0; - while ((p_buf = (BT_HDR *)fixed_queue_dequeue(p_port->tx.queue, 0)) != NULL) { - osi_free (p_buf); + if (p_port->tx.queue) { + while ((p_buf = (BT_HDR *)fixed_queue_dequeue(p_port->tx.queue, 0)) != NULL) { + osi_free (p_buf); + } } - p_port->tx.queue_size = 0; osi_mutex_global_unlock();