<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Weird bucket choice or number in FcCharSetFreezeOrig() and FcCharSetFindFrozen()"
href="https://bugs.freedesktop.org/show_bug.cgi?id=101352">101352</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Weird bucket choice or number in FcCharSetFreezeOrig() and FcCharSetFindFrozen()
</td>
</tr>
<tr>
<th>Product</th>
<td>fontconfig
</td>
</tr>
<tr>
<th>Version</th>
<td>2.12
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>minor
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>library
</td>
</tr>
<tr>
<th>Assignee</th>
<td>fontconfig-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>f.rougon@free.fr
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>freedesktop@behdad.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=131807" name="attach_131807" title="Possible fix in 'git format-patch' format">attachment 131807</a> <a href="attachment.cgi?id=131807&action=edit" title="Possible fix in 'git format-patch' format">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=101352&attachment=131807'>[review]</a>
Possible fix in 'git format-patch' format
Hello,
As written at:
<a href="https://lists.freedesktop.org/archives/fontconfig/2017-June/005929.html">https://lists.freedesktop.org/archives/fontconfig/2017-June/005929.html</a>
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).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>