1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Peter Krempa 2020-11-19 10:39:45 +01:00
parent 6524af14c2
commit 62903cb11f

View File

@ -561,7 +561,7 @@ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr)
static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
g_autoptr(virshDomain) dom = NULL;
const char *source = NULL;
const char *target = NULL;
const char *driver = NULL;
@ -583,7 +583,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
const char *stype = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *xml = NULL;
g_autofree char *xml = NULL;
struct stat st;
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
@ -783,8 +783,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
}
cleanup:
VIR_FREE(xml);
virshDomainFree(dom);
return functionReturn;
}