From 91085cd9904aaba9b529f3e3ffaa6da4bcb7f89f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 12 Mar 2026 08:57:35 -0600 Subject: [PATCH] Guard VarData itemCount overflow (#5836) Reject oversized merged VarData row sets before assigning them to the 16-bit itemCount field. This avoids truncating the serialized allocation size and prevents the subsequent row write loop from running out of bounds. src/hb-ot-layout-common.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Co-authored-by: Quang Luong --- src/hb-ot-layout-common.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 054730135..a9c03db3e 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2971,7 +2971,9 @@ struct VarData } if (unlikely (!c->extend_min (this))) return_trace (false); - itemCount = row_count; + if (unlikely (!c->check_assign (itemCount, row_count, + HB_SERIALIZE_ERROR_INT_OVERFLOW))) + return_trace (false); int min_threshold = has_long ? -65536 : -128; int max_threshold = has_long ? +65535 : +127;