From b1a0a4c228f5adb438e44a78e5c485249cb6a89a Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 7 Apr 2025 18:39:21 +0000 Subject: [PATCH] In OT::VarData::Serialize don't attempt to serialize an empty set of rows. Protects against incorrectly accessing rows[0] when rows is empty. --- src/hb-ot-layout-common.hh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 7b466fb0b..3c734e6a8 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2863,8 +2863,13 @@ struct VarData const hb_vector_t*>& rows) { TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (this))) return_trace (false); unsigned row_count = rows.length; + if (!row_count) { + // Nothing to serialize, will be empty. + return false; + } + + if (unlikely (!c->extend_min (this))) return_trace (false); itemCount = row_count; int min_threshold = has_long ? -65536 : -128;