2005-04-18 Roman Kennke <roman@kennke.org>
authorRoman Kennke <roman@kennke.org>
Mon, 18 Apr 2005 20:47:01 +0000 (20:47 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Mon, 18 Apr 2005 20:47:01 +0000 (20:47 +0000)
* java/awt/BorderLayout.java
(calcSize): Check for overflow when component sizes are added.

From-SVN: r98347

libjava/ChangeLog
libjava/java/awt/BorderLayout.java

index 3e9ba57418ad2293fe98db7f9b7504edfbf4e195..6a96409dc7fa0c3226e551d2de6abfc64ea7a161 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-18  Roman Kennke  <roman@kennke.org>
+
+       * java/awt/BorderLayout.java
+       (calcSize): Check for overflow when component sizes are added.
+
 2005-04-18  Robert Schuster <thebohemian@gmx.net>
 
        * java/awt/AWTEvent.java (toString): Added case
index 7a955d38139f3693125c735e878161855824d4ba..284faf0f3aaef3b31c420e1fdb5f9283182ee999 100644 (file)
@@ -700,6 +700,10 @@ calcSize(Container target, int what)
       Dimension cdim = calcCompSize(center, what);
 
       int width = edim.width + cdim.width + wdim.width + (hgap * 2);
+      // check for overflow
+      if (width < edim.width || width < cdim.width || width < cdim.width)
+          width = Integer.MAX_VALUE;
+
       if (ndim.width > width)
        width = ndim.width;
       if (sdim.width > width)
@@ -713,7 +717,13 @@ calcSize(Container target, int what)
       if (wdim.height > height)
        height = wdim.height;
 
-      height += (ndim.height + sdim.height + (vgap * 2) + ins.top + ins.bottom);
+      int addedHeight = height + (ndim.height + sdim.height + (vgap * 2)
+                                  + ins.top + ins.bottom);
+      // check for overflow
+      if (addedHeight < height)
+          height = Integer.MAX_VALUE;
+      else
+          height = addedHeight;
 
       return(new Dimension(width, height));
     }