From d393274dded3f54394caa13f7ce27b2adbf8683f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 20 Nov 2014 15:13:14 +0200 Subject: [PATCH] shared/gatt: Fix dereference before NULL check warnings Add NULL check otherwise constructions like below give warnings: ... uint8_t pdu[4 + get_uuid_len(uuid)]; if (!att || !uuid || uuid->type == BT_UUID_UNSPEC) ... --- src/shared/gatt-helpers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c index d0bee3f6e..dc4a8e86b 100644 --- a/src/shared/gatt-helpers.c +++ b/src/shared/gatt-helpers.c @@ -588,6 +588,9 @@ static void put_uuid_le(const bt_uuid_t *src, void *dst) static inline int get_uuid_len(const bt_uuid_t *uuid) { + if (!uuid) + return 0; + return (uuid->type == BT_UUID16) ? 2 : 16; } -- 2.47.3