summaryrefslogtreecommitdiff
path: root/attrib/att.c
diff options
context:
space:
mode:
authorAnderson Lizardo <anderson.lizardo@openbossa.org>2011-09-20 22:49:10 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2011-09-22 20:01:28 +0900
commit2acb6b1a3ae530f6b952488bca1d5500fe2ea035 (patch)
tree14748f09ec27ac2ba561704161b91a7c7f94880e /attrib/att.c
parentfef3e7c0025b955b7ef4d6ff68cd6aa921f4475a (diff)
downloadbluez-2acb6b1a3ae530f6b952488bca1d5500fe2ea035.tar.gz
Fix memory allocation of struct attribute
On commit 6a6da5de107e192f62ce2ecdde96eae985181df0 the struct attribute "data[0]" member was replaced with a dynamically allocated "data" pointer. This commit fixes remaining places where the old allocation scheme was still assumed.
Diffstat (limited to 'attrib/att.c')
-rw-r--r--attrib/att.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/attrib/att.c b/attrib/att.c
index 1b95c4532..c3cbf868a 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -868,11 +868,10 @@ struct attribute *dec_indication(const uint8_t *pdu, int len)
if (len < min_len)
return NULL;
- a = g_malloc0(sizeof(struct attribute) + len - min_len);
- a->len = len - min_len;
-
+ a = g_new0(struct attribute, 1);
a->handle = att_get_u16(&pdu[1]);
- memcpy(a->data, &pdu[3], a->len);
+ a->len = len - min_len;
+ a->data = g_memdup(&pdu[3], a->len);
return a;
}