mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
nodedev: fix potential leak of command
When returning early due to errors, cmd will be leaked. Use an autoptr to handle these early returns without leaking memory. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
2384b6cade
commit
d0913302a8
@ -724,7 +724,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
|||||||
char **errbuf)
|
char **errbuf)
|
||||||
{
|
{
|
||||||
g_autofree char *parent_addr = NULL;
|
g_autofree char *parent_addr = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
const char *subcommand = virMdevctlCommandTypeToString(cmd_type);
|
const char *subcommand = virMdevctlCommandTypeToString(cmd_type);
|
||||||
g_autofree char *inbuf = NULL;
|
g_autofree char *inbuf = NULL;
|
||||||
|
|
||||||
@ -787,7 +787,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
|||||||
|
|
||||||
virCommandSetErrorBuffer(cmd, errbuf);
|
virCommandSetErrorBuffer(cmd, errbuf);
|
||||||
|
|
||||||
return cmd;
|
return g_steal_pointer(&cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user