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>
This commit is contained in:
parent
720fdd6fa9
commit
6cfcd864a4
|
@ -132,7 +132,6 @@ int qemu_acl_insert(qemu_acl *acl,
|
||||||
const char *match,
|
const char *match,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
qemu_acl_entry *entry;
|
|
||||||
qemu_acl_entry *tmp;
|
qemu_acl_entry *tmp;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -142,13 +141,14 @@ int qemu_acl_insert(qemu_acl *acl,
|
||||||
return qemu_acl_append(acl, deny, match);
|
return qemu_acl_append(acl, deny, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTAILQ_FOREACH(tmp, &acl->entries, next) {
|
||||||
|
i++;
|
||||||
|
if (i == index) {
|
||||||
|
qemu_acl_entry *entry;
|
||||||
entry = g_malloc(sizeof(*entry));
|
entry = g_malloc(sizeof(*entry));
|
||||||
entry->match = g_strdup(match);
|
entry->match = g_strdup(match);
|
||||||
entry->deny = deny;
|
entry->deny = deny;
|
||||||
|
|
||||||
QTAILQ_FOREACH(tmp, &acl->entries, next) {
|
|
||||||
i++;
|
|
||||||
if (i == index) {
|
|
||||||
QTAILQ_INSERT_BEFORE(tmp, entry, next);
|
QTAILQ_INSERT_BEFORE(tmp, entry, next);
|
||||||
acl->nentries++;
|
acl->nentries++;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue