[Bug 513582] segfault in FTC_CMapCache_Lookup()

bugzilla at redhat.com bugzilla at redhat.com
Sat Sep 26 12:02:59 UTC 2009


Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug.


https://bugzilla.redhat.com/show_bug.cgi?id=513582





--- Comment #31 from mpsuzuki at hiroshima-u.ac.jp  2009-09-26 08:02:58 EDT ---
Created an attachment (id=362757)
 --> (https://bugzilla.redhat.com/attachment.cgi?id=362757)
Patch to introduce the unions to the parts violating strict aliasing.

Behdad,

Following is what you suggested?
Attached is a patch to do similar modifications for all part
warned as violating strict aliasing.

diff --git a/src/cache/ftccmap.c b/src/cache/ftccmap.c
index 50a6189..8fb3387 100644
--- a/src/cache/ftccmap.c
+++ b/src/cache/ftccmap.c
@@ -283,11 +283,15 @@
   {
     FTC_Cache         cache = FTC_CACHE( cmap_cache );
     FTC_CMapQueryRec  query;
-    FTC_CMapNode      node;
     FT_Error          error;
     FT_UInt           gindex = 0;
     FT_UInt32         hash;
     FT_Int            no_cmap_change = 0;
+    union
+    {
+      FTC_Node      node;
+      FTC_CMapNode  cmap;
+    } ftc_unode;


     if ( cmap_index < 0 )
@@ -371,20 +375,20 @@

 #if 1
     FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query,
-                          node, error );
+                          ftc_unode.node, error );
 #else
-    error = FTC_Cache_Lookup( cache, hash, &query, (FTC_Node*) &node );
+    error = FTC_Cache_Lookup( cache, hash, &query, &(ftc_unode.node) );
 #endif
     if ( error )
       goto Exit;

-    FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX );
+    FT_ASSERT( (FT_UInt)( char_code - ftc_unode.cmap->first ) <
FTC_CMAP_INDICES_MAX );

     /* something rotten can happen with rogue clients */
-    if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) )
+    if ( (FT_UInt)( char_code - ftc_unode.cmap->first >= FTC_CMAP_INDICES_MAX
) )
       return 0;

-    gindex = node->indices[char_code - node->first];
+    gindex = ftc_unode.cmap->indices[char_code - ftc_unode.cmap->first];
     if ( gindex == FTC_CMAP_UNKNOWN )
     {
       FT_Face  face;
@@ -392,7 +396,7 @@

       gindex = 0;

-      error = FTC_Manager_LookupFace( cache->manager, node->face_id, &face );
+      error = FTC_Manager_LookupFace( cache->manager, ftc_unode.cmap->face_id,
&face );
       if ( error )
         goto Exit;

@@ -413,7 +417,7 @@
           FT_Set_Charmap( face, old );
       }

-      node->indices[char_code - node->first] = (FT_UShort)gindex;
+      ftc_unode.cmap->indices[char_code - ftc_unode.cmap->first] =
(FT_UShort)gindex;
     }

   Exit:

-- 
Configure bugmail: https://bugzilla.redhat.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.




More information about the fonts-bugs mailing list