[OffsetTo] Try catching nullable offsets to unbounded types

Doesn't catch all cases; if type is not fully defined at
OffsetTo time, we can't know.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1300
to the best we can do.
This commit is contained in:
Behdad Esfahbod 2022-07-15 16:03:55 -06:00
parent 1327d8e3df
commit 9843f07658
1 changed files with 4 additions and 0 deletions

View File

@ -304,6 +304,10 @@ struct _hb_has_null<Type, true>
template <typename Type, typename OffsetType, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null>
{
// Make sure Type is not unbounded; works only for types that are fully defined at OffsetTo time.
static_assert (has_null == false ||
(hb_has_null_size (Type) || !hb_has_min_size (Type)), "");
HB_DELETE_COPY_ASSIGN (OffsetTo);
OffsetTo () = default;