From: Gonglei <arei.gong...@huawei.com> 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 <arei.gong...@huawei.com> --- 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