提交 493a005d 编写于 作者: B Behdad Esfahbod

[set] In add_sorted_array(), bail if data is not sorted

上级 a7bd6d7a
...@@ -286,20 +286,24 @@ struct hb_set_t ...@@ -286,20 +286,24 @@ struct hb_set_t
if (unlikely (in_error)) return false; if (unlikely (in_error)) return false;
if (!count) return true; if (!count) return true;
hb_codepoint_t g = *array; hb_codepoint_t g = *array;
hb_codepoint_t last_g = g;
while (count) while (count)
{ {
unsigned int m = get_major (g); unsigned int m = get_major (g);
page_t *page = page_for_insert (g); if (unlikely (!page)) return false; page_t *page = page_for_insert (g); if (unlikely (!page)) return false;
unsigned int start = major_start (m);
unsigned int end = major_start (m + 1); unsigned int end = major_start (m + 1);
do do
{ {
/* If we try harder we can change the following comparison to <=;
* Not sure if it's worth it. */
if (g < last_g) return false;
last_g = g;
page->add (g); page->add (g);
array++; array++;
count--; count--;
} }
while (count && (g = *array, start <= g && g < end)); while (count && (g = *array, g < end));
} }
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册