diff options
author | Ludek Finstrle <luf@pzkagis.cz> | 2012-10-18 10:39:21 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-19 10:41:25 +0300 |
commit | d24560cf46154b7364eeea8d9b3f77e50b6ee63a (patch) | |
tree | f820dc350217904f556950c3d5abce960d042043 /src | |
parent | fc10fc4edbdbe59b4dde7c515501f3881b2f7456 (diff) |
attrib: Fix memory leak if att_data_list_alloc fails
Fix for memory leak which was introduced in commit
f8619bef3406a2134082dc41c208105fe028c09f.
Diffstat (limited to 'src')
-rw-r--r-- | src/attrib-server.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/attrib-server.c b/src/attrib-server.c index ea27b137..4489edc2 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -490,9 +490,11 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start, length = g_slist_length(groups); adl = att_data_list_alloc(length, last_size + 4); - if (adl == NULL) + if (adl == NULL) { + g_slist_free_full(groups, g_free); return enc_error_resp(ATT_OP_READ_BY_GROUP_REQ, start, ATT_ECODE_UNLIKELY, pdu, len); + } for (i = 0, l = groups; l; l = l->next, i++) { uint8_t *value; @@ -577,9 +579,11 @@ static uint16_t read_by_type(struct gatt_channel *channel, uint16_t start, length += 2; adl = att_data_list_alloc(num, length); - if (adl == NULL) + if (adl == NULL) { + g_slist_free(types); return enc_error_resp(ATT_OP_READ_BY_TYPE_REQ, start, ATT_ECODE_UNLIKELY, pdu, len); + } for (i = 0, l = types; l; i++, l = l->next) { uint8_t *value; @@ -655,9 +659,11 @@ static uint16_t find_info(struct gatt_channel *channel, uint16_t start, } adl = att_data_list_alloc(num, length + 2); - if (adl == NULL) + if (adl == NULL) { + g_slist_free(info); return enc_error_resp(ATT_OP_FIND_INFO_REQ, start, ATT_ECODE_UNLIKELY, pdu, len); + } for (i = 0, l = info; l; i++, l = l->next) { uint8_t *value; |