summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2012-01-23 21:21:51 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-01-24 14:59:09 +0200
commit19a4979a95454964bf69f2dfd48afa1756f0b0ff (patch)
treeb65b50848f8f8a8657254ce53108596d9ecdf5a1 /plugins
parent7d705873845d6e165b7b09cfb2c56b0443ce0e91 (diff)
downloadbluez-19a4979a95454964bf69f2dfd48afa1756f0b0ff.tar.gz
hciops: Fix memory leak when loading keys
If we need a copy of those keys we should copy them.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hciops.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/hciops.c b/plugins/hciops.c
index d4d219c0b..f4af63756 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -3563,6 +3563,7 @@ static int hciops_restore_powered(int index)
static int hciops_load_keys(int index, GSList *keys, gboolean debug_keys)
{
struct dev_info *dev = &devs[index];
+ GSList *l;
DBG("hci%d keys %d debug_keys %d", index, g_slist_length(keys),
debug_keys);
@@ -3570,7 +3571,16 @@ static int hciops_load_keys(int index, GSList *keys, gboolean debug_keys)
if (dev->keys != NULL)
return -EEXIST;
- dev->keys = keys;
+ for (l = keys; l; l = l->next) {
+ struct link_key_info *orig, *dup;
+
+ orig = l->data;
+
+ dup = g_memdup(orig, sizeof(*orig));
+
+ dev->keys = g_slist_prepend(dev->keys, dup);
+ }
+
dev->debug_keys = debug_keys;
return 0;