[subset] Fix div-by-zero

This commit is contained in:
Behdad Esfahbod 2018-09-07 10:24:22 -04:00
parent 21bf147054
commit 5f17dbc302
1 changed files with 3 additions and 0 deletions

View File

@ -51,6 +51,9 @@ _plan_estimate_subset_table_size (hb_subset_plan_t *plan,
unsigned int src_glyphs = plan->source->get_num_glyphs (); unsigned int src_glyphs = plan->source->get_num_glyphs ();
unsigned int dst_glyphs = plan->glyphset->get_population (); unsigned int dst_glyphs = plan->glyphset->get_population ();
if (unlikely (!src_glyphs))
return 512 + table_len;
return 512 + (unsigned int) (table_len * sqrt ((double) dst_glyphs / src_glyphs)); return 512 + (unsigned int) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
} }