mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 00:41:09 +01:00
[ot-tag] guard against NULL language in hb_ot_tags_to_script_and_language (#6085)
hb_ot_tag_to_language returns NULL for HB_OT_TAG_DEFAULT_LANGUAGE, and hb_language_to_string returns NULL for it, so the script-suffix path called strlen on a NULL pointer whenever the primary script tag did not match the input. Skip the suffix construction when there is no base language string and leave the default (NULL) language in place. Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
This commit is contained in:
1 parent
53900fd388
commit
cce964cb4f
2 files changed
+5
-2
No files matched your search
+2
-2
@@ -668,10 +668,10 @@ hb_ot_tags_to_script_and_language (hb_tag_t script_tag,
|
||||
primary_script_tag,
|
||||
nullptr, nullptr);
|
||||
*language = hb_ot_tag_to_language (language_tag);
|
||||
if (script_count == 0 || primary_script_tag[0] != script_tag)
|
||||
const char *lang_str = *language ? hb_language_to_string (*language) : nullptr;
|
||||
if (lang_str && (script_count == 0 || primary_script_tag[0] != script_tag))
|
||||
{
|
||||
unsigned char *buf;
|
||||
const char *lang_str = hb_language_to_string (*language);
|
||||
size_t len = strlen (lang_str);
|
||||
buf = (unsigned char *) hb_malloc (len + 16);
|
||||
if (unlikely (!buf))
|
||||
|
||||
@@ -291,6 +291,9 @@ test_ot_tags_to_script_and_language (void)
|
||||
test_tags_to_script_and_language ("dev2", "MAR", "Deva", "mr-x-hbsc-64657632");
|
||||
test_tags_to_script_and_language ("dev3", "MAR", "Deva", "mr");
|
||||
test_tags_to_script_and_language ("qaa", "QTZ0", "Qaaa", "x-hbot-51545a30-hbsc-71616120");
|
||||
/* Default language tag maps to a NULL language; the script-suffix path
|
||||
* must not dereference it. */
|
||||
test_tags_to_script_and_language ("DFLT", "dflt", "", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in new issue
Block a user