On vboxStorageVolCreateXML(), virGetUserDirectory() was called without
freeing its content later on.
Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
src/vbox/vbox_storage.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 790b0e4997..7f240c5333 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -410,6 +410,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
resultCodeUnion resultCode;
virStorageVolPtr ret = NULL;
g_autoptr(virStorageVolDef) def = NULL;
+ g_autofree char *homedir = NULL;
if (!data->vboxObj)
return ret;
@@ -442,8 +443,10 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
}
/* If target.path isn't given, use default path ~/.VirtualBox/image_name */
- if (!def->target.path)
- def->target.path = g_strdup_printf("%s/.VirtualBox/%s",
virGetUserDirectory(), def->name);
+ if (!def->target.path) {
+ homedir = virGetUserDirectory();
+ def->target.path = g_strdup_printf("%s/.VirtualBox/%s", homedir,
def->name);
+ }
VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16);
if (!hddFormatUtf16 || !hddNameUtf16)
--
2.24.1