Diff between fc7be1e8677158796c321d03618df13cdca270b4 and 4465c577778d812702d752dfd2812e25a2f69b31

Changed Files

File Additions Deletions Status
src/shared/gatt-db.c +13 -0 modified

Full Patch

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index fe272de..b441405 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -379,6 +379,9 @@ static void gen_hash_m(struct gatt_db_attribute *attr, void *user_data)
 	uint8_t *data;
 	size_t len;
 
+	if (!attr || !attr->value)
+		return;
+
 	if (bt_uuid_len(&attr->uuid) != 2)
 		return;
 
@@ -1005,6 +1008,10 @@ service_insert_characteristic(struct gatt_db_service *service,
 
 	/* Update handle of characteristic value_handle if it has changed */
 	put_le16(value_handle, &value[1]);
+
+	if (!(*chrc) || !(*chrc)->value)
+		return NULL;
+
 	if (memcmp((*chrc)->value, value, len))
 		memcpy((*chrc)->value, value, len);
 
@@ -1229,6 +1236,9 @@ service_insert_included(struct gatt_db_service *service, uint16_t handle,
 	uint16_t included_handle, len = 0;
 	int index;
 
+	if (!include || !include->value || !include->service || !service)
+		return NULL;
+
 	included = include->service;
 
 	/* Adjust include to point to the first attribute */
@@ -1386,6 +1396,9 @@ static void find_by_type(struct gatt_db_attribute *attribute, void *user_data)
 		if (search_data->value_len != attribute->value_len)
 			return;
 
+		if (!attribute || !attribute->value)
+			return;
+
 		if (memcmp(attribute->value, search_data->value,
 					search_data->value_len))
 			return;