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 <jjongsma@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
Jonathon Jongsma 2018-12-03 15:37:27 -06:00
parent ba9c79b55e
commit c07cc4f89f

View File

@ -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);
}