Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9673d62 authored by Zhihai Xu's avatar Zhihai Xu
Browse files

SDP: Allocate proper sized scratch buffer for SDP response

The buffer allocated for attribute response is being reused
for subsequent requests for an SDP connection. Check the
buffer size before using for subsequent requests and
reallocate if required.

Change-Id: Ib00aff2c4512192c29265cf0adb89e380adf0b35
parent f51905d3
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -380,8 +380,14 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
    else
    {
        /* Get a scratch buffer to store response */
        if (!p_ccb->rsp_list)
        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
        {
            /* Free and reallocate if the earlier allocated buffer is small */
            if (p_ccb->rsp_list)
            {
                GKI_freebuf (p_ccb->rsp_list);
            }

            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
            if (p_ccb->rsp_list == NULL)
            {
@@ -624,8 +630,14 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
    else
    {
        /* Get a scratch buffer to store response */
        if (!p_ccb->rsp_list)
        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
        {
            /* Free and reallocate if the earlier allocated buffer is small */
            if (p_ccb->rsp_list)
            {
                GKI_freebuf (p_ccb->rsp_list);
            }

            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
            if (p_ccb->rsp_list == NULL)
            {