Bug 101348

Summary: fc-lang doesn't gracefully handle the case where the last language initial is < 'z'
Product: fontconfig Reporter: Florent Rougon <f.rougon>
Component: libraryAssignee: fontconfig-bugs
Status: RESOLVED FIXED QA Contact: Behdad Esfahbod <freedesktop>
Severity: minor    
Priority: medium CC: akira
Version: 2.12   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix as Git commit (obtained with 'git format-patch)

Description Florent Rougon 2017-06-08 13:54:35 UTC
Created attachment 131801 [details] [review]
Fix as Git commit (obtained with 'git format-patch)

As reported at https://lists.freedesktop.org/archives/fontconfig/2017-June/005940.html :

FcLangSetIndex() contains code like this:

  low = fcLangCharSetRanges[firstChar - 'a'].begin;
  high = fcLangCharSetRanges[firstChar - 'a'].end;
  /* no matches */
  if (low > high)

The assumption behind this test didn't hold before the attached
commit/patch, unless there is at least one language name that starts
with 'z' (which is thankfully the case in our world :-). If the last
language name in lexicographic order starts for instance with 'x',
this change ensures that fcLangCharSetRanges['y' - 'a'].begin and
fcLangCharSetRanges['z' - 'a'].begin are equal to NUM_LANG_CHAR_SET,
in order to make the above assumption correct in all cases.
Comment 1 Akira TAGOH 2017-06-09 04:50:35 UTC
looks good to me. thank you for catching this up. merged in git.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.