Diff between 0f3796bc200078e68d8e484327d22cd9285a7ecd and 111186b3bf80c2cbe008dd3625badc0d5c32f896

Changed Files

File Additions Deletions Status
attrib/gattrib.c +22 -1 modified

Full Patch

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index cfa3b78..7fe7647 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);
 }