Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings
@ 2014-11-20 13:13 Andrei Emeltchenko
  2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-20 13:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

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 d0bee3f..dc4a8e8 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;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-27 12:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 13:13 [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
2014-11-27  9:04 ` [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-27 12:58 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox