[kern/kerx] Adjust bounds check

This commit is contained in:
Behdad Esfahbod 2018-10-09 22:52:41 -04:00
parent c66f7f8c5d
commit 27db859416
2 changed files with 6 additions and 10 deletions

View File

@ -112,11 +112,9 @@ struct KerxSubTableFormat2
unsigned int l = *(this+leftClassTable).get_value (left, num_glyphs);
unsigned int r = *(this+rightClassTable).get_value (right, num_glyphs);
unsigned int offset = l + r;
const FWORD *arr = &(this+array);
if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
return 0;
const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
if (unlikely ((const char *) v < (const char *) &array ||
(const char *) v > (const char *) end - 2))
return 0;
return *v;
}

View File

@ -194,11 +194,9 @@ struct KernSubTableFormat2
unsigned int l = (this+leftClassTable).get_class (left);
unsigned int r = (this+rightClassTable).get_class (right);
unsigned int offset = l + r;
const FWORD *arr = &(this+array);
if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
return 0;
const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
if (unlikely ((const char *) v < (const char *) &array ||
(const char *) v > (const char *) end - 2))
return 0;
return *v;
}