[subset] fix memory leak when map insert fails.

This commit is contained in:
Garret Rieger 2021-03-29 16:39:44 -07:00
parent 2397689387
commit 8741914a80
2 changed files with 12 additions and 5 deletions

View File

@ -485,7 +485,7 @@ struct RecordListOfScript : RecordListOf<Script>
if (!ret) c->serializer->revert (snap); if (!ret) c->serializer->revert (snap);
else out->len++; else out->len++;
} }
return_trace (true); return_trace (true);
} }
}; };
@ -699,8 +699,15 @@ struct Script
if (c->visitedScript (this)) return; if (c->visitedScript (this)) return;
if (!c->script_langsys_map->has (script_index)) if (!c->script_langsys_map->has (script_index))
c->script_langsys_map->set (script_index, hb_set_create ()); {
hb_set_t* empty_set = hb_set_create ();
c->script_langsys_map->set (script_index, empty_set);
if (!c->script_langsys_map->has (script_index)) {
hb_set_destroy (empty_set);
return;
}
}
unsigned langsys_count = get_lang_sys_count (); unsigned langsys_count = get_lang_sys_count ();
if (has_default_lang_sys ()) if (has_default_lang_sys ())
{ {
@ -2244,7 +2251,7 @@ struct ClassDefFormat2
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (rangeRecord[i].value != klass) continue; if (rangeRecord[i].value != klass) continue;
if (g != HB_SET_VALUE_INVALID) if (g != HB_SET_VALUE_INVALID)
{ {
if (g >= rangeRecord[i].first && if (g >= rangeRecord[i].first &&
@ -2253,7 +2260,7 @@ struct ClassDefFormat2
if (g > rangeRecord[i].last) if (g > rangeRecord[i].last)
continue; continue;
} }
g = rangeRecord[i].first - 1; g = rangeRecord[i].first - 1;
while (hb_set_next (glyphs, &g)) while (hb_set_next (glyphs, &g))
{ {