[goffice] Canvas: clip crazy widget height/width to avoid X11 crash.



commit a2bcc21bfcac4aeda6ded65663a272a39294f5fc
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 24 11:53:51 2013 -0400

    Canvas: clip crazy widget height/width to avoid X11 crash.

 ChangeLog                   |    5 +++++
 goffice/canvas/goc-widget.c |   22 ++++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a511a5f..f64d5de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-24  Morten Welinder  <terra gnome org>
+
+       * goffice/canvas/goc-widget.c (goc_offscreen_box_size_allocate):
+       Clip crazy height/width to avoid program crash.
+
 2013-04-19  Morten Welinder  <terra gnome org>
 
        * goffice/gtk/go-action-combo-color.c
diff --git a/goffice/canvas/goc-widget.c b/goffice/canvas/goc-widget.c
index 9fe8f3c..904d638 100644
--- a/goffice/canvas/goc-widget.c
+++ b/goffice/canvas/goc-widget.c
@@ -321,13 +321,15 @@ goc_offscreen_box_size_allocate (GtkWidget     *widget,
 
        gtk_widget_set_allocation (widget, allocation);
 
-       if (gtk_widget_get_realized (widget))
+       if (gtk_widget_get_realized (widget)) {
+               /* See https://bugzilla.gnome.org/show_bug.cgi?id=698758 */
+               guint h = MIN (allocation->height, 0x7fff);
+               guint w = MIN (allocation->width, 0x7fff);
                gdk_window_move_resize (gtk_widget_get_window (widget),
                                        allocation->x,
                                        allocation->y,
-                                       allocation->width,
-                                       allocation->height);
-
+                                       w, h);
+       }
 
        if (offscreen_box->child
            && gtk_widget_get_visible (offscreen_box->child)) {
@@ -335,18 +337,18 @@ goc_offscreen_box_size_allocate (GtkWidget     *widget,
                GtkAllocation child_allocation;
 
                gtk_widget_get_preferred_size (offscreen_box->child,
-                                            &child_requisition, NULL);
+                                              &child_requisition, NULL);
                child_allocation.x = 0;
                child_allocation.y = 0;
                child_allocation.width = child_requisition.width;
                child_allocation.height = child_requisition.height;
 
                if (gtk_widget_get_realized (widget))
-               gdk_window_move_resize (offscreen_box->offscreen_window,
-                                       child_allocation.x,
-                                       child_allocation.y,
-                                       child_allocation.width,
-                                       child_allocation.height);
+                       gdk_window_move_resize (offscreen_box->offscreen_window,
+                                               child_allocation.x,
+                                               child_allocation.y,
+                                               child_allocation.width,
+                                               child_allocation.height);
 
                gtk_widget_size_allocate (offscreen_box->child, &child_allocation);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]