[ot-tags] Fix `min_subtag_len` calculations
This commit is contained in:
parent
0b1c2ff96a
commit
e3e685e5ee
|
@ -1019,14 +1019,12 @@ for initial, items in sorted (complex_tags.items ()):
|
||||||
if not tags:
|
if not tags:
|
||||||
continue
|
continue
|
||||||
subtag_len = 0
|
subtag_len = 0
|
||||||
subtag_len += len(lt.script) if lt.script is not None else 0
|
subtag_len += 1 + len (lt.script) if lt.script is not None else 0
|
||||||
subtag_len += len(lt.region) if lt.region is not None else 0
|
subtag_len += 1 + len (lt.region) if lt.region is not None else 0
|
||||||
subtag_len += len(lt.variant) if lt.variant is not None else 0
|
subtag_len += 1 + len (lt.variant) if lt.variant is not None else 0
|
||||||
min_subtag_len = min(subtag_len, min_subtag_len)
|
min_subtag_len = min(subtag_len, min_subtag_len)
|
||||||
min_subtag_len += 1 # For initial '-'
|
|
||||||
|
|
||||||
print (' if (limit - lang_str > %d ||' % min_subtag_len)
|
print (' if (limit - lang_str >= %d)' % (min_subtag_len + 2))
|
||||||
print (" (limit - lang_str == %d && *lang_str == '-'))" % min_subtag_len)
|
|
||||||
print (' {')
|
print (' {')
|
||||||
print (" const char *p = strchr (lang_str, '-');")
|
print (" const char *p = strchr (lang_str, '-');")
|
||||||
print (" if (!p || p >= limit || limit - p < %i) goto out;" % min_subtag_len)
|
print (" if (!p || p >= limit || limit - p < %i) goto out;" % min_subtag_len)
|
||||||
|
@ -1058,7 +1056,7 @@ for initial, items in sorted (complex_tags.items ()):
|
||||||
print ()
|
print ()
|
||||||
print (' };')
|
print (' };')
|
||||||
print (' for (i = 0; i < %s && i < *count; i++)' % len (tags))
|
print (' for (i = 0; i < %s && i < *count; i++)' % len (tags))
|
||||||
print (' tags[i] = possible_tags[i];')
|
print ('\ttags[i] = possible_tags[i];')
|
||||||
print (' *count = i;')
|
print (' *count = i;')
|
||||||
print (' return true;')
|
print (' return true;')
|
||||||
print (' }')
|
print (' }')
|
||||||
|
|
|
@ -1642,8 +1642,7 @@ hb_ot_tags_from_complex_language (const char *lang_str,
|
||||||
unsigned int *count /* IN/OUT */,
|
unsigned int *count /* IN/OUT */,
|
||||||
hb_tag_t *tags /* OUT */)
|
hb_tag_t *tags /* OUT */)
|
||||||
{
|
{
|
||||||
if (limit - lang_str > 5 ||
|
if (limit - lang_str >= 7)
|
||||||
(limit - lang_str == 5 && *lang_str == '-'))
|
|
||||||
{
|
{
|
||||||
const char *p = strchr (lang_str, '-');
|
const char *p = strchr (lang_str, '-');
|
||||||
if (!p || p >= limit || limit - p < 5) goto out;
|
if (!p || p >= limit || limit - p < 5) goto out;
|
||||||
|
|
Loading…
Reference in New Issue