summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-11-08 18:27:41 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-11-08 18:27:41 +0000
commit4b2738a1f913e98780d1344d08948ad324433b70 (patch)
tree520871e75657839c435307510593f53d98707252 /gdk
parent76f0399c32b6945decb8958d2450a9f87deb20cc (diff)
downloadgdk-pixbuf-4b2738a1f913e98780d1344d08948ad324433b70.tar.gz
Ignore icons if they would make the request large enough to cause Xlib to
2005-11-08 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore icons if they would make the request large enough to cause Xlib to loose the connection. (#320909, Claudio Saavedra)
Diffstat (limited to 'gdk')
-rw-r--r--gdk/x11/gdkwindow-x11.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index c8851ac49..d25e2ddf6 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3967,6 +3967,12 @@ gdk_x11_window_set_user_time (GdkWindow *window,
toplevel->user_time = timestamp_long;
}
+#define GDK_SELECTION_MAX_SIZE(display) \
+ MIN(262144, \
+ XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
+ ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
+ : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
+
/**
* gdk_window_set_icon_list:
* @window: The #GdkWindow toplevel window to set the icon of.
@@ -3995,6 +4001,7 @@ gdk_window_set_icon_list (GdkWindow *window,
gint x, y;
gint n_channels;
GdkDisplay *display;
+ gint n;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -4005,7 +4012,7 @@ gdk_window_set_icon_list (GdkWindow *window,
l = pixbufs;
size = 0;
-
+ n = 0;
while (l)
{
pixbuf = l->data;
@@ -4014,8 +4021,16 @@ gdk_window_set_icon_list (GdkWindow *window,
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
+ /* silently ignore overlarge icons */
+ if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display))
+ {
+ g_warning ("gdk_window_set_icon_list: icons too large");
+ break;
+ }
+
+ n++;
size += 2 + width * height;
-
+
l = g_list_next (l);
}
@@ -4023,7 +4038,7 @@ gdk_window_set_icon_list (GdkWindow *window,
l = pixbufs;
p = data;
- while (l)
+ while (l && n > 0)
{
pixbuf = l->data;
@@ -4056,6 +4071,7 @@ gdk_window_set_icon_list (GdkWindow *window,
}
l = g_list_next (l);
+ n--;
}
if (size > 0)