Return-Path: From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 7/7] core/gatt: Check if attribute is valid Date: Thu, 19 Mar 2015 15:13:20 +0200 Message-Id: <1426770800-21649-7-git-send-email-luiz.dentz@gmail.com> In-Reply-To: <1426770800-21649-1-git-send-email-luiz.dentz@gmail.com> References: <1426770800-21649-1-git-send-email-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Luiz Augusto von Dentz This checks the return of gatt_db_get_attribute and fail if return NULL. --- src/gatt-client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gatt-client.c b/src/gatt-client.c index 8f67db3..608f96d 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1339,8 +1339,15 @@ static struct characteristic *characteristic_create( gatt_db_attribute_get_char_data(attr, &chrc->handle, &chrc->value_handle, &chrc->props, &uuid); + chrc->attr = gatt_db_get_attribute(service->client->db, chrc->value_handle); + if (!chrc->attr) { + error("Attribute 0x%04x not found", chrc->value_handle); + characteristic_free(chrc); + return NULL; + } + bt_uuid_to_uuid128(&uuid, &chrc->uuid); chrc->path = g_strdup_printf("%s/char%04x", service->path, -- 2.1.0