Fix hb_bytes_t.cmp() for realz this time

This commit is contained in:
Behdad Esfahbod 2018-11-10 15:43:16 -05:00
parent 929f07dbfc
commit 534e1d7694
1 changed files with 6 additions and 4 deletions

View File

@ -530,10 +530,12 @@ struct hb_bytes_t
inline int cmp (const hb_bytes_t &a) const
{
if (!len) return 0; /* glibc's memcmp() args are declared nonnull. Meh. */
int r = memcmp (a.arrayZ, arrayZ, len);
if (r) return r;
unsigned int l = MIN(a.len, len);
if (l) /* glibc's memcmp() args are declared nonnull. Meh. */
{
int r = memcmp (a.arrayZ, arrayZ, l);
if (r) return r;
}
return a.len < len ? -1 : a.len > len ? +1 : 0;
}