[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.
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 2c1c49b..8e57a68 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -304,6 +304,10 @@
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;