bugThe FreeType Project - Bugs: bug #24119, overflow in compare routine

 
 

bug #24119: overflow in compare routine

Submitted by:  bram tassyns <bramt>
Submitted on:  Fri 22 Aug 2008 11:03:04 AM UTC  
 
Severity: 3 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.3.8

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 23 Aug 2008 07:52:08 PM UTC, comment #1:

Applied, thanks.

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Fri 22 Aug 2008 11:03:04 AM UTC, original submission:

I encountered this problem on macintosh with the standard font ArnoPro-Bold.otf. When iterating over the unicode charmap we reached "space.ac" before "space".

psmodule.c, compare_uni_maps is not always correct.
When substracting the two FT_UInt32 values you might get a value that overflows the simple int return type. I propose fixing this by replacing the minus operator by two compare operators.

Fix:

/* ft_qsort callback to sort the unicode map */
FT_CALLBACK_DEF( int )
compare_uni_maps( const void* a,
const void* b )
{
PS_UniMap* map1 = (PS_UniMap*)a;
PS_UniMap* map2 = (PS_UniMap*)b;
FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode );
FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode );

/* sort base glyphs before glyph variants */
if ( unicode1 == unicode2 )
{
if ( map1->unicode > map2->unicode )
return 1;
else if ( map1->unicode < map2->unicode )
return -1;
else
return 0;
}
else
{
if ( unicode1 > unicode2 )
return 1;
else if ( unicode1 < unicode2 )
return -1;
else
return 0;
}
}

bram tassyns <bramt>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by bramt (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 23 Aug 2008 07:52:08 PM UTCwlStatusNone=>Fixed
      Assigned toNone=>wl
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.8

    Back to the top


    Powered by Savane 3.1-cleanup1