changeset 12836:5f5a7709ac30

8190289: More refactoring for client deserialization cases Reviewed-by: prr, azvegint, rhalade, skoivu
author serb
date Tue, 07 Nov 2017 09:22:18 -0800
parents 9b819798e7b0
children cb84156d54b2
files src/share/classes/java/awt/geom/Path2D.java src/share/classes/javax/swing/text/html/CSS.java
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/geom/Path2D.java	Sat Nov 04 17:23:38 2017 -0700
+++ b/src/share/classes/java/awt/geom/Path2D.java	Tue Nov 07 09:22:18 2017 -0800
@@ -25,13 +25,14 @@
 
 package java.awt.geom;
 
+import java.awt.Rectangle;
 import java.awt.Shape;
-import java.awt.Rectangle;
-import sun.awt.geom.Curve;
 import java.io.Serializable;
 import java.io.StreamCorruptedException;
 import java.util.Arrays;
 
+import sun.awt.geom.Curve;
+
 /**
  * The {@code Path2D} class provides a simple, yet flexible
  * shape which represents an arbitrary geometric path.
@@ -2583,9 +2584,12 @@
             throw new java.io.InvalidObjectException(iae.getMessage());
         }
 
-        pointTypes = new byte[(nT < 0) ? INIT_SIZE : nT];
-        if (nC < 0) {
-            nC = INIT_SIZE * 2;
+        // Accept the size from the stream only if it is less than INIT_SIZE
+        // otherwise the size will be based on the real data in the stream
+        pointTypes = new byte[(nT < 0 || nT > INIT_SIZE) ? INIT_SIZE : nT];
+        final int initX2 = INIT_SIZE * 2;
+        if (nC < 0 || nC > initX2) {
+            nC = initX2;
         }
         if (storedbl) {
             ((Path2D.Double) this).doubleCoords = new double[nC];
--- a/src/share/classes/javax/swing/text/html/CSS.java	Sat Nov 04 17:23:38 2017 -0700
+++ b/src/share/classes/javax/swing/text/html/CSS.java	Tue Nov 07 09:22:18 2017 -0800
@@ -3352,7 +3352,7 @@
         s.defaultReadObject();
         // Reconstruct the hashtable.
         int numValues = s.readInt();
-        valueConvertor = new Hashtable<Object, Object>(Math.max(1, numValues));
+        valueConvertor = new Hashtable<Object, Object>();
         while (numValues-- > 0) {
             Object key = s.readObject();
             Object value = s.readObject();