From bf44e53bf4d9159eccd57da50a479762a6cb7beb Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Mon, 26 May 2014 16:06:22 +0200 Subject: [PATCH] android/gatt: Fix possible memory leak in write request If write cannot be executed, remove data from queue and free allocated memory. --- android/gatt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/gatt.c b/android/gatt.c index e41a69e6a..721785a4f 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -4969,8 +4969,11 @@ static uint8_t write_req_request(const uint8_t *cmd, uint16_t cmd_len, } if (!gatt_db_write(gatt_db, handle, 0, value, vlen, cmd[0], - &dev->bdaddr)) + &dev->bdaddr)) { + queue_remove(dev->pending_requests, data); + free(data); return ATT_ECODE_UNLIKELY; + } return 0; } -- 2.47.3