[Fontconfig-bugs] [Bug 101352] New: Weird bucket choice or number in FcCharSetFreezeOrig() and FcCharSetFindFrozen()

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Jun 8 14:21:11 UTC 2017


https://bugs.freedesktop.org/show_bug.cgi?id=101352

            Bug ID: 101352
           Summary: Weird bucket choice or number in FcCharSetFreezeOrig()
                    and FcCharSetFindFrozen()
           Product: fontconfig
           Version: 2.12
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: medium
         Component: library
          Assignee: fontconfig-bugs at lists.freedesktop.org
          Reporter: f.rougon at free.fr
        QA Contact: freedesktop at behdad.org

Created attachment 131807
  --> https://bugs.freedesktop.org/attachment.cgi?id=131807&action=edit
Possible fix in 'git format-patch' format

Hello,

As written at:
https://lists.freedesktop.org/archives/fontconfig/2017-June/005929.html

The following looks odd to me in src/fccharset.c:

#define FC_CHAR_SET_HASH_SIZE    67

[...]

static FcBool
FcCharSetFreezeOrig (FcCharSetFreezer *freezer, const FcCharSet *orig, const
FcCharSet *frozen)
{
    FcCharSetOrigEnt    **bucket = &freezer->orig_hash_table[((uintptr_t) orig)
& FC_CHAR_SET_HASH_SIZE];

[...]

static const FcCharSet *
FcCharSetFindFrozen (FcCharSetFreezer *freezer, const FcCharSet *orig)
{
    FcCharSetOrigEnt    **bucket = &freezer->orig_hash_table[((uintptr_t) orig)
& FC_CHAR_SET_HASH_SIZE];

[...]

It seems to me that either FC_CHAR_SET_HASH_SIZE should be defined as a
power of two minus one (2**n - 1 for some n), or the two occurrences of
the & operator in the above lines should be replaced with a % operator.
Otherwise, at most 8 buckets among the 67 available in
freezer->orig_hash_table can effectively be used
(67 = 64 + 2 + 1 and 2**3 = 8).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig-bugs/attachments/20170608/e97443c1/attachment.html>


More information about the Fontconfig-bugs mailing list