summaryrefslogtreecommitdiff
path: root/attrib
diff options
context:
space:
mode:
authorArman Uguray <armansito@chromium.org>2014-12-08 16:40:43 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-12-09 14:48:45 +0200
commit111186b3bf80c2cbe008dd3625badc0d5c32f896 (patch)
treebf7c41adec0e1b110019fe4ca42468e9bd6fed02 /attrib
parent0f3796bc200078e68d8e484327d22cd9285a7ecd (diff)
downloadbluez-111186b3bf80c2cbe008dd3625badc0d5c32f896.tar.gz
attrib: Check if attrib is NULL in functions
This patch adds an early return to attrib/gattrib functions if the attrib argument is NULL.
Diffstat (limited to 'attrib')
-rw-r--r--attrib/gattrib.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index cfa3b78a3..7fe764788 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -258,6 +258,9 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
bt_att_response_func_t response_cb = NULL;
bt_att_destroy_func_t destroy_cb = NULL;
+ if (!attrib)
+ return 0;
+
if (!pdu || !len)
return 0;
@@ -280,11 +283,17 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
gboolean g_attrib_cancel(GAttrib *attrib, guint id)
{
+ if (!attrib)
+ return FALSE;
+
return bt_att_cancel(attrib->att, id);
}
gboolean g_attrib_cancel_all(GAttrib *attrib)
{
+ if (!attrib)
+ return FALSE;
+
return bt_att_cancel_all(attrib->att);
}
@@ -294,6 +303,9 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
{
struct attrib_callbacks *cb = NULL;
+ if (!attrib)
+ return 0;
+
if (func || notify) {
cb = new0(struct attrib_callbacks, 1);
if (!cb)
@@ -315,7 +327,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
{
- if (!len)
+ if (!attrib || !len)
return NULL;
*len = attrib->buflen;
@@ -324,6 +336,9 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
{
+ if (!attrib)
+ return FALSE;
+
/*
* Clients of this expect a buffer to use.
*
@@ -341,10 +356,16 @@ gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
gboolean g_attrib_unregister(GAttrib *attrib, guint id)
{
+ if (!attrib)
+ return FALSE;
+
return bt_att_unregister(attrib->att, id);
}
gboolean g_attrib_unregister_all(GAttrib *attrib)
{
+ if (!attrib)
+ return false;
+
return bt_att_unregister_all(attrib->att);
}