changeset 10895:b7d09522002b

8074098: 2D_Font/Bug8067699 test fails with SIGBUS crash on Solaris Sparc Reviewed-by: bae, mschoene
author prr
date Tue, 10 Mar 2015 14:54:33 -0700
parents 3f9845510b47
children f732971e3d20
files src/share/native/sun/font/layout/MorphTables.cpp src/share/native/sun/font/layout/MorphTables2.cpp
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/font/layout/MorphTables.cpp	Tue Mar 10 14:52:55 2015 -0700
+++ b/src/share/native/sun/font/layout/MorphTables.cpp	Tue Mar 10 14:54:33 2015 -0700
@@ -54,6 +54,10 @@
     for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) {
         if (chain > 0) {
             le_uint32 chainLength = SWAPL(chainHeader->chainLength);
+            if (chainLength & 0x03) { // incorrect alignment for 32 bit tables
+                success = LE_MEMORY_ALLOCATION_ERROR; // as good a choice as any
+                return;
+            }
             chainHeader.addOffset(chainLength, success);
         }
         FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags);
@@ -66,6 +70,10 @@
         for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) {
             if (subtable > 0) {
                 le_int16 length = SWAPW(subtableHeader->length);
+                if (length & 0x03) { // incorrect alignment for 32 bit tables
+                    success = LE_MEMORY_ALLOCATION_ERROR; // as good a choice as any
+                    return;
+                }
                 subtableHeader.addOffset(length, success);
             }
             SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
--- a/src/share/native/sun/font/layout/MorphTables2.cpp	Tue Mar 10 14:52:55 2015 -0700
+++ b/src/share/native/sun/font/layout/MorphTables2.cpp	Tue Mar 10 14:54:33 2015 -0700
@@ -59,6 +59,10 @@
   for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain++) {
         if (chain>0) {
           le_uint32 chainLength = SWAPL(chainHeader->chainLength);
+          if (chainLength & 0x03) { // incorrect alignment for 32 bit tables
+              success = LE_MEMORY_ALLOCATION_ERROR; // as good a choice as any
+              return;
+          }
           chainHeader.addOffset(chainLength, success); // Don't increment the first time
         }
         FeatureFlags flag = SWAPL(chainHeader->defaultFlags);
@@ -188,6 +192,10 @@
         for (subtable = 0;  LE_SUCCESS(success) && subtable < nSubtables; subtable++) {
             if(subtable>0)  {
               le_uint32 length = SWAPL(subtableHeader->length);
+              if (length & 0x03) { // incorrect alignment for 32 bit tables
+                  success = LE_MEMORY_ALLOCATION_ERROR; // as good a choice as any
+                  return;
+              }
               subtableHeader.addOffset(length, success); // Don't addOffset for the last entry.
             }
             le_uint32 coverage = SWAPL(subtableHeader->coverage);