From e9af9062c0e1be1f479a43ad878cda622c781a56 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 27 Jun 2022 15:38:42 -0600 Subject: [PATCH] [gvar] Optimize unpack_deltas --- src/hb-ot-var-gvar-table.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index 77d6ab47d..44cab8874 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -608,9 +608,10 @@ struct gvar for (unsigned int i = 0; i < num_deltas; i++) { unsigned int pt_index = apply_to_all ? i : indices[i]; - deltas[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ - deltas[pt_index].x += x_deltas.arrayZ[i] * scalar; - deltas[pt_index].y += y_deltas.arrayZ[i] * scalar; + if (unlikely (pt_index >= deltas.length)) continue; + deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ + deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i] * scalar; + deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i] * scalar; } /* infer deltas for unreferenced points */