RHBZ:
https://bugzilla.redhat.com/show_bug.cgi?id=924574
Valgrind defects memory error:
==19297== Invalid free() / delete / delete[] / realloc()
==19297== at 0x4A077A6: free (vg_replace_malloc.c:446)
==19297== by 0x350F24D79E: g_free (in /usr/lib64/libglib-2.0.so.0.3400.2)
==19297== by 0x4C2C03F: gvir_sandbox_config_add_host_include_file
(libvirt-sandbox-config.c:1319)
==19297== by 0x401FB7: main (virt-sandbox.c:171)
==19297== Address 0x4f2094c is 12 bytes inside a block of size 18 alloc'd
==19297== at 0x4A0883C: malloc (vg_replace_malloc.c:270)
==19297== by 0x350F24D68E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3400.2)
==19297== by 0x350F263F0B: g_strdup (in /usr/lib64/libglib-2.0.so.0.3400.2)
==19297== by 0x4C2BF95: gvir_sandbox_config_add_host_include_file
(libvirt-sandbox-config.c:1292)
==19297== by 0x401FB7: main (virt-sandbox.c:171)
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
libvirt-sandbox/libvirt-sandbox-config.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-config.c
b/libvirt-sandbox/libvirt-sandbox-config.c
index fc852f5..a98f40b 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.c
+++ b/libvirt-sandbox/libvirt-sandbox-config.c
@@ -1337,6 +1337,7 @@ gboolean gvir_sandbox_config_add_host_include_file(GVirSandboxConfig
*config,
error))) {
const gchar *host;
gchar *guest;
+ const gchar *relguest;
GVirSandboxConfigMount *mnt = NULL;
GList *mnts = NULL;
gchar *tmp;
@@ -1354,8 +1355,10 @@ gboolean
gvir_sandbox_config_add_host_include_file(GVirSandboxConfig *config,
mnt = GVIR_SANDBOX_CONFIG_MOUNT(mnts->data);
const gchar *target = gvir_sandbox_config_mount_get_target(mnt);
if (g_str_has_prefix(guest, target)) {
- guest = guest + strlen(target);
+ relguest = guest + strlen(target);
break;
+ } else {
+ relguest = guest;
}
mnt = NULL;
mnts = mnts->next;
@@ -1367,7 +1370,7 @@ gboolean gvir_sandbox_config_add_host_include_file(GVirSandboxConfig
*config,
return FALSE;
}
- gvir_sandbox_config_mount_add_include(GVIR_SANDBOX_CONFIG_MOUNT(mnt), host,
guest);
+ gvir_sandbox_config_mount_add_include(GVIR_SANDBOX_CONFIG_MOUNT(mnt), host,
relguest);
g_free(guest);
g_free(line);
}
--
1.7.1