--- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java Mon Aug 18 14:03:21 2014 +0100
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java Tue Aug 19 10:32:16 2014 -0700
@@ -490,12 +490,33 @@
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
{
- s.defaultReadObject();
+ ObjectInputStream.GetField f = s.readFields();
+
+ imageObserver = (ImageObserver) f.get("imageObserver", null);
+ description = (String) f.get("description", null);
+ width = f.get("width", -1);
+ height = f.get("height", -1);
+ accessibleContext = (AccessibleImageIcon) f.get("accessibleContext", null);
int w = s.readInt();
int h = s.readInt();
int[] pixels = (int[])(s.readObject());
+ if (pixels == null && (w != -1 || h != -1)) {
+ throw new IllegalStateException("Inconsistent width and height"
+ + " for null image [" + w + ", " + h + "]");
+ }
+
+ if (pixels != null && (w < 0 || h < 0)) {
+ throw new IllegalStateException("Inconsistent width and height"
+ + " for image [" + w + ", " + h + "]");
+ }
+
+ if (w != getIconWidth() || h != getIconHeight()) {
+ throw new IllegalStateException("Inconsistent width and height"
+ + " for image [" + w + ", " + h + "]");
+ }
+
if (pixels != null) {
Toolkit tk = Toolkit.getDefaultToolkit();
ColorModel cm = ColorModel.getRGBdefault();