diff --git a/android/gatt.c b/android/gatt.c
index 7cf612f..6b57145 100644
--- a/android/gatt.c
+++ b/android/gatt.c
* So we need to free service memory only once but we need to destroy
* two queues
*/
- if (srvc->primary)
- queue_destroy(srvc->included, NULL);
+ queue_destroy(srvc->included, NULL);
free(srvc);
}
return NULL;
}
+ s->included = queue_new();
+ if (!s->included) {
+ error("gatt: Cannot allocate memory for included queue");
+ queue_destroy(s->chars, NULL);
+ free(s);
+ return NULL;
+ }
+
if (bt_string_to_uuid(&s->id.uuid, uuid) < 0) {
error("gatt: Cannot convert string to uuid");
queue_destroy(s->chars, NULL);
/* Put primary service to our local list */
s->primary = primary;
- if (s->primary) {
+ if (s->primary)
memcpy(&s->prim, data, sizeof(s->prim));
- } else {
+ else
memcpy(&s->incl, data, sizeof(s->incl));
- return s;
- }
-
- /* For primary service allocate queue for included services */
- s->included = queue_new();
- if (!s->included) {
- queue_destroy(s->chars, NULL);
- free(s);
- return NULL;
- }
return s;
}