From 760eb1bf9398bd37103ca879e825fad9bef4bfdd Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 3 Jun 2019 05:48:04 -0700 Subject: [PATCH] Reapply possible bsearch overflow fix Originally introduced in 21ede86 (#1314) but as it wasn't applied to hb_bsearch accidentally removed while merging hb_bsearch_r to it. --- src/hb-algs.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 699ac0240..0b34f7106 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -613,7 +613,7 @@ hb_bsearch (const void *key, const void *base, int min = 0, max = (int) nmemb - 1; while (min <= max) { - int mid = (min + max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; const void *p = (const void *) (((const char *) base) + (mid * size)); int c = compar (key, p, ds...); if (c < 0)