diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 4ac9c3ca2..540783d4a 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1906,8 +1906,13 @@ struct VarRegionList axisCount = src->axisCount; regionCount = region_map.get_population (); if (unlikely (!c->allocate_size (get_size () - min_size))) return_trace (false); + unsigned int region_count = src->get_region_count (); for (unsigned int r = 0; r < regionCount; r++) - memcpy (&axesZ[axisCount * r], &src->axesZ[axisCount * region_map.backward (r)], VarRegionAxis::static_size * axisCount); + { + unsigned int backward = region_map.backward (r); + if (backward >= region_count) return_trace (false); + memcpy (&axesZ[axisCount * r], &src->axesZ[axisCount * backward], VarRegionAxis::static_size * axisCount); + } return_trace (true); } diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5708764082864128 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5708764082864128 new file mode 100644 index 000000000..96cfb0065 Binary files /dev/null and b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5708764082864128 differ