2014-07-03 11:32:56

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH] android/gatt: Fix memory leak

From: Andrei Emeltchenko <[email protected]>

Fixes clang warnings:
...
android/gatt.c:2823:1: warning: Potential leak of memory pointed to by
'cb_data'
...
---
android/gatt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index d672bdb..9e23398 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2957,7 +2957,8 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
goto failed;
}

- if (cmd->write_type != GATT_WRITE_TYPE_NO_RESPONSE) {
+ if (cmd->write_type != GATT_WRITE_TYPE_NO_RESPONSE &&
+ cmd->write_type != GATT_WRITE_TYPE_SIGNED) {
cb_data = create_char_op_data(cmd->conn_id, &srvc->id, &ch->id,
cmd->srvc_id.is_primary);
if (!cb_data) {
--
1.9.1



2014-12-24 11:16:33

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH] android/gatt: Fix memory leak

Hi Andrei,

On Friday 19 of December 2014 15:50:20 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> ---
> android/gatt.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 2534836..6248f07 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -6129,6 +6129,7 @@ static uint8_t find_info_handle(const uint8_t *cmd,
> uint16_t cmd_len, int iterator = 0;
> uint16_t start, end;
> uint16_t len, queue_len;
> + uint8_t ret = 0;
>
> DBG("");
>
> @@ -6206,13 +6207,13 @@ static uint8_t find_info_handle(const uint8_t *cmd,
> uint16_t cmd_len, ATT_FIND_INFO_RESP_FMT_128BIT, adl, rsp,
> rsp_size);
> if (!len)
> - return ATT_ECODE_UNLIKELY;
> + ret = ATT_ECODE_UNLIKELY;
>
> *length = len;
> att_data_list_free(adl);
> queue_destroy(temp, NULL);
>
> - return 0;
> + return ret;
> }
>
> static uint8_t find_by_type_request(const uint8_t *cmd, uint16_t cmd_len,

Applied, thanks.

--
BR
Szymon Janc