changeset 4992:7a5c8c6f1c6b

7141914: Draw glyph cause JVM crash Reviewed-by: bae, igor
author prr
date Fri, 03 Feb 2012 09:57:45 -0800
parents f7dda4bbf1f9
children 996cd6e8d00e
files src/share/classes/sun/font/FileFont.java src/share/classes/sun/font/StandardGlyphVector.java src/share/classes/sun/font/SunFontManager.java src/share/classes/sun/font/TrueTypeFont.java
diffstat 4 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/font/FileFont.java	Sat Jan 28 22:47:07 2012 -0800
+++ b/src/share/classes/sun/font/FileFont.java	Fri Feb 03 09:57:45 2012 -0800
@@ -163,7 +163,9 @@
                 }
             }
         }
-        scaler.dispose();
+        if (scaler != null) {
+            scaler.dispose();
+        }
         scaler = FontScaler.getNullScaler();
     }
 
--- a/src/share/classes/sun/font/StandardGlyphVector.java	Sat Jan 28 22:47:07 2012 -0800
+++ b/src/share/classes/sun/font/StandardGlyphVector.java	Fri Feb 03 09:57:45 2012 -0800
@@ -1740,8 +1740,9 @@
                                                      tx,
                                                      sgv.font.getStyle(),
                                                      aa, fm);
-
-            FontStrike strike = sgv.font2D.getStrike(desc);  // !!! getStrike(desc, false)
+            // Get the strike via the handle. Shouldn't matter
+            // if we've invalidated the font but its an extra precaution.
+            FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)
 
             return new GlyphStrike(sgv, strike, dx, dy);
         }
--- a/src/share/classes/sun/font/SunFontManager.java	Sat Jan 28 22:47:07 2012 -0800
+++ b/src/share/classes/sun/font/SunFontManager.java	Fri Feb 03 09:57:45 2012 -0800
@@ -2619,6 +2619,9 @@
         physicalFonts.remove(oldFont.fullName);
         fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH));
         FontFamily.remove(oldFont);
+        if (oldFont instanceof FileFont) {
+            ((FileFont)oldFont).deregisterFontAndClearStrikeCache();
+        }
 
         if (localeFullNamesToFont != null) {
             Map.Entry[] mapEntries =
--- a/src/share/classes/sun/font/TrueTypeFont.java	Sat Jan 28 22:47:07 2012 -0800
+++ b/src/share/classes/sun/font/TrueTypeFont.java	Fri Feb 03 09:57:45 2012 -0800
@@ -1037,6 +1037,9 @@
             if (head_Table != null && head_Table.capacity() >= 18) {
                 ShortBuffer sb = head_Table.asShortBuffer();
                 upem = sb.get(9) & 0xffff;
+                if (upem < 16 || upem > 16384) {
+                    upem = 2048;
+                }
             }
 
             ByteBuffer os2_Table = getTableBuffer(os_2Tag);