[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] vnc: fix memory leak at vnc_display_open
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH 2/3] vnc: fix memory leak at vnc_display_open |
Date: |
Thu, 23 Oct 2014 13:39:42 +0800 |
From: Gonglei <address@hidden>
When using qmp change vnc interface, will leak
memory of vs->display and vs->ws_display (if configed).
Free them before calling g_strdup()/g_strconcat().
Signed-off-by: Gonglei <address@hidden>
---
ui/vnc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ui/vnc.c b/ui/vnc.c
index 628a7ba..38229a7 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3036,6 +3036,7 @@ void vnc_display_open(DisplayState *ds, const char
*display, Error **errp)
if (strcmp(display, "none") == 0)
return;
+ g_free(vs->display);
vs->display = g_strdup(display);
vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
@@ -3083,6 +3084,7 @@ void vnc_display_open(DisplayState *ds, const char
*display, Error **errp)
} else {
host = g_strndup(":", 1);
}
+ g_free(vs->ws_display);
vs->ws_display = g_strconcat(host, port, NULL);
g_free(host);
g_free(port);
--
1.7.12.4