summaryrefslogtreecommitdiff
path: root/util/acl.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-11-15 18:06:45 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2014-11-17 11:48:56 +0100
commit6cfcd864a468eb7bd3da20a5462b5af1791581d3 (patch)
treed99c11cbc43f08b4ddd604cecd6f67d2ba61119d /util/acl.c
parent720fdd6fa92df9041316e94816ab7e56abaed4e9 (diff)
acl: fix memory leak
If 'i != index' for all acl->entries, variable entry leaks the storage it points to. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/acl.c')
-rw-r--r--util/acl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/acl.c b/util/acl.c
index 938b7ae2d2..571d686156 100644
--- a/util/acl.c
+++ b/util/acl.c
@@ -132,7 +132,6 @@ int qemu_acl_insert(qemu_acl *acl,
const char *match,
int index)
{
- qemu_acl_entry *entry;
qemu_acl_entry *tmp;
int i = 0;
@@ -142,13 +141,14 @@ int qemu_acl_insert(qemu_acl *acl,
return qemu_acl_append(acl, deny, match);
}
- entry = g_malloc(sizeof(*entry));
- entry->match = g_strdup(match);
- entry->deny = deny;
-
QTAILQ_FOREACH(tmp, &acl->entries, next) {
i++;
if (i == index) {
+ qemu_acl_entry *entry;
+ entry = g_malloc(sizeof(*entry));
+ entry->match = g_strdup(match);
+ entry->deny = deny;
+
QTAILQ_INSERT_BEFORE(tmp, entry, next);
acl->nentries++;
break;