session: Only create a hashtable if apply_monitor_geometry vfunc exists

Creating the monitors hashtable only after checking for the existence of
apply_monitor_geometry vfunc avoids leaking the hashtable in the case
where the vfunc doesn't exist.

Related: rhbz#1267184
This commit is contained in:
Fabiano Fidêncio 2015-10-21 14:12:48 +02:00
parent 50f7d3dff8
commit 73b55b3e1b

View File

@ -405,13 +405,15 @@ virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
VirtViewerSessionClass *klass;
gboolean all_fullscreen = TRUE;
/* GHashTable<gint, GdkRectangle*> */
GHashTable *monitors = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
GHashTable *monitors;
GList *l;
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
if (!klass->apply_monitor_geometry)
return;
monitors = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
for (l = self->priv->displays; l; l = l->next) {
VirtViewerDisplay *d = VIRT_VIEWER_DISPLAY(l->data);
guint nth = 0;