Re: [PATCH BlueZ] Fix memory leak when loading keys
From: Anderson Lizardo <hidden>
Date: 2012-01-24 11:46:30
Hi Johan, On Tue, Jan 24, 2012 at 6:46 AM, Johan Hedberg [off-list ref] wrote:
Hi Lizardo, On Tue, Jan 24, 2012, Anderson Lizardo wrote:quoted
On Mon, Jan 23, 2012 at 8:21 PM, Vinicius Costa Gomes [off-list ref] wrote:quoted
@@ -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); + } +No need to cleanup dev->keys first?Take a look at the first two lines of context. The function bails out if dev->keys is anything else than NULL.
Right. Oops :) Regards, -- Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil