From ca9bc90b7467f27c8172b46895fa5754ef08416f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 19 Mar 2015 13:58:34 +0200 Subject: [PATCH] core/gatt: Check if attribute is valid 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 6a9a1dfac..863492a68 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.47.3