提交 ab6de9f0 编写于 作者: F Fabiano Fidêncio

vbox: Don't leak virGetUserDirectory()'s output

On vboxStorageVolCreateXML(), virGetUserDirectory() was called without
freeing its content later on.
Signed-off-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 dd478cc5
...@@ -410,6 +410,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -410,6 +410,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
resultCodeUnion resultCode; resultCodeUnion resultCode;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
g_autoptr(virStorageVolDef) def = NULL; g_autoptr(virStorageVolDef) def = NULL;
g_autofree char *homedir = NULL;
if (!data->vboxObj) if (!data->vboxObj)
return ret; return ret;
...@@ -442,8 +443,10 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -442,8 +443,10 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
} }
/* If target.path isn't given, use default path ~/.VirtualBox/image_name */ /* If target.path isn't given, use default path ~/.VirtualBox/image_name */
if (!def->target.path) if (!def->target.path) {
def->target.path = g_strdup_printf("%s/.VirtualBox/%s", virGetUserDirectory(), def->name); homedir = virGetUserDirectory();
def->target.path = g_strdup_printf("%s/.VirtualBox/%s", homedir, def->name);
}
VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16); VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16);
if (!hddFormatUtf16 || !hddNameUtf16) if (!hddFormatUtf16 || !hddNameUtf16)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册