[mutter] [constraints] Avoid overflow when window maximum size hint is set to INT_MAX



commit 2f63d321d1822ca2928e2d4c148873c306e61b3b
Author: Xu Li <xu li intel com>
Date:   Mon Aug 3 14:13:34 2009 +0100

    [constraints] Avoid overflow when window maximum size hint is set to INT_MAX
    
    When calculating maximum permissible size of our frame window, we need to
    avoid an overflow if the application set its max size hint to INT_MAX.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=590627

 src/core/constraints.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 57a6a1d..a8308cb 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -700,8 +700,17 @@ get_size_limits (const MetaWindow        *window,
 
       min_size->width  += fw;
       min_size->height += fh;
-      max_size->width  += fw;
-      max_size->height += fh;
+      /* Do check to avoid overflow (e.g. max_size->width & max_size->height
+       * may be set to G_MAXINT by meta_set_normal_hints()).
+       */
+      if (max_size->width < (G_MAXINT - fw))
+        max_size->width += fw;
+      else
+        max_size->width = G_MAXINT;
+      if (max_size->height < (G_MAXINT - fh))
+        max_size->height += fh;
+      else
+        max_size->height = G_MAXINT;
     }
 }
 



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