[kerx] Fix Format2 index calc again

This commit is contained in:
Behdad Esfahbod 2018-11-28 15:24:30 -05:00
parent 9e4f03b6ed
commit 42a2b496e4
2 changed files with 15 additions and 1 deletions

View File

@ -689,6 +689,13 @@ struct ObsoleteTypes
return (offset - ((const char *) array - (const char *) base)) / sizeof (T); return (offset - ((const char *) array - (const char *) base)) / sizeof (T);
} }
template <typename T> template <typename T>
static inline unsigned int byteOffsetToIndex (unsigned int offset,
const void *base,
const T *array)
{
return offsetToIndex (offset, base, array);
}
template <typename T>
static inline unsigned int wordOffsetToIndex (unsigned int offset, static inline unsigned int wordOffsetToIndex (unsigned int offset,
const void *base, const void *base,
const T *array) const T *array)
@ -712,6 +719,13 @@ struct ExtendedTypes
return offset; return offset;
} }
template <typename T> template <typename T>
static inline unsigned int byteOffsetToIndex (unsigned int offset,
const void *base,
const T *array)
{
return offset / 2;
}
template <typename T>
static inline unsigned int wordOffsetToIndex (unsigned int offset, static inline unsigned int wordOffsetToIndex (unsigned int offset,
const void *base, const void *base,
const T *array) const T *array)

View File

@ -255,7 +255,7 @@ struct KerxSubTableFormat1
unsigned int tuple_count = MAX (1u, table->header.tuple_count ()); unsigned int tuple_count = MAX (1u, table->header.tuple_count ());
unsigned int kern_idx = Format1EntryT::kernActionIndex (entry); unsigned int kern_idx = Format1EntryT::kernActionIndex (entry);
kern_idx = Types::offsetToIndex (kern_idx, &table->machine, kernAction.arrayZ); kern_idx = Types::byteOffsetToIndex (kern_idx, &table->machine, kernAction.arrayZ);
const FWORD *actions = &kernAction[kern_idx]; const FWORD *actions = &kernAction[kern_idx];
if (!c->sanitizer.check_array (actions, depth, tuple_count)) if (!c->sanitizer.check_array (actions, depth, tuple_count))
{ {