summaryrefslogtreecommitdiffstats
path: root/hidd
diff options
context:
space:
mode:
Diffstat (limited to 'hidd')
-rw-r--r--hidd/sdp.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/hidd/sdp.c b/hidd/sdp.c
index b256748e..1c6f25f4 100644
--- a/hidd/sdp.c
+++ b/hidd/sdp.c
@@ -73,7 +73,7 @@ static void epox_endian_quirk(unsigned char *data, int size)
static int store_device_info(const bdaddr_t *src, const bdaddr_t *dst, struct hidp_connadd_req *req)
{
char filename[PATH_MAX + 1], addr[18], *str, *desc;
- int i, size;
+ int i, err, size;
ba2str(src, addr);
create_name(filename, PATH_MAX, STORAGEDIR, addr, "hidd");
@@ -98,10 +98,16 @@ static int store_device_info(const bdaddr_t *src, const bdaddr_t *dst, struct hi
req->subclass, req->country, req->parser, desc,
req->flags, req->name);
+ free(desc);
+
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
ba2str(dst, addr);
- return textfile_put(filename, addr, str);
+ err = textfile_put(filename, addr, str);
+
+ free(str);
+
+ return err;
}
int get_stored_device_info(const bdaddr_t *src, const bdaddr_t *dst, struct hidp_connadd_req *req)
@@ -143,8 +149,10 @@ int get_stored_device_info(const bdaddr_t *src, const bdaddr_t *dst, struct hidp
req->rd_size = strlen(desc) / 2;
req->rd_data = malloc(req->rd_size);
- if (!req->rd_data)
+ if (!req->rd_data) {
+ free(desc);
return -ENOMEM;
+ }
memset(tmp, 0, sizeof(tmp));
for (i = 0; i < req->rd_size; i++) {
@@ -152,6 +160,8 @@ int get_stored_device_info(const bdaddr_t *src, const bdaddr_t *dst, struct hidp
req->rd_data[i] = (uint8_t) strtol(tmp, NULL, 16);
}
+ free(desc);
+
return 0;
}