From b7b73fcfa6ef1787acbe753b1402aa2d795d1725 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 10 Feb 2015 21:26:20 +0100 Subject: [PATCH] android/gatt: Fix not sending MTU exchange response g_attrib_set_mtu can invalidate buffer obtained from g_attrib_get_buffer so it must not be called after g_attrib_get_buffer and before g_attrib_send. --- android/gatt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/gatt.c b/android/gatt.c index 1a6de64f9..13f4dfa53 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -6169,6 +6169,9 @@ static uint8_t mtu_att_handle(const uint8_t *cmd, uint16_t cmd_len, if (!get_local_mtu(dev, &mtu)) return ATT_ECODE_UNLIKELY; + if (!update_mtu(dev, rmtu)) + return ATT_ECODE_UNLIKELY; + rsp = g_attrib_get_buffer(dev->attrib, &length); /* Respond with our MTU */ @@ -6176,9 +6179,6 @@ static uint8_t mtu_att_handle(const uint8_t *cmd, uint16_t cmd_len, if (!len) return ATT_ECODE_UNLIKELY; - if (!update_mtu(dev, rmtu)) - return ATT_ECODE_UNLIKELY; - g_attrib_send(dev->attrib, 0, rsp, len, NULL, NULL, NULL); return 0; -- 2.47.3