1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-10 05:17:59 +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 static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainPtr dom = NULL; g_autoptr(virshDomain) dom = NULL;
const char *source = NULL; const char *source = NULL;
const char *target = NULL; const char *target = NULL;
const char *driver = NULL; const char *driver = NULL;
@ -583,7 +583,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
const char *stype = NULL; const char *stype = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *xml = NULL; g_autofree char *xml = NULL;
struct stat st; struct stat st;
bool current = vshCommandOptBool(cmd, "current"); bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config"); bool config = vshCommandOptBool(cmd, "config");
@ -783,8 +783,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
} }
cleanup: cleanup:
VIR_FREE(xml);
virshDomainFree(dom);
return functionReturn; return functionReturn;
} }