From c07cc4f89fc89df864cc33d53de3ec2668afc51e Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Mon, 3 Dec 2018 15:37:27 -0600 Subject: [PATCH] Avoid potential memory leak in spice session If j == -1, the memory allocated for rect will leak. So move the allocation after the test. Signed-off-by: Jonathon Jongsma Acked-by: Victor Toso --- src/virt-viewer-session-spice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c index cb06af2..8223881 100644 --- a/src/virt-viewer-session-spice.c +++ b/src/virt-viewer-session-spice.c @@ -1067,11 +1067,11 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self) displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); for (l = initial_displays; l != NULL; l = l->next) { - GdkRectangle* rect = g_new0(GdkRectangle, 1);; gint j = virt_viewer_app_get_initial_monitor_for_display(app, GPOINTER_TO_INT(l->data)); if (j == -1) continue; + GdkRectangle* rect = g_new0(GdkRectangle, 1);; gdk_screen_get_monitor_geometry(screen, j, rect); g_hash_table_insert(displays, l->data, rect); }