From fc72a1d22dc9efd52a9fa43143673253b20b0c69 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 26 Jun 2022 16:42:01 -0600 Subject: [PATCH] [glyf] Add a pre-allocation for phantom points --- src/OT/glyf/SimpleGlyph.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OT/glyf/SimpleGlyph.hh b/src/OT/glyf/SimpleGlyph.hh index 2f1eb9e09..0d49d5cdc 100644 --- a/src/OT/glyf/SimpleGlyph.hh +++ b/src/OT/glyf/SimpleGlyph.hh @@ -158,7 +158,8 @@ struct SimpleGlyph if (unlikely (!bytes.check_range (&endPtsOfContours[num_contours - 1]))) return false; unsigned int num_points = endPtsOfContours[num_contours - 1] + 1; - points_.resize (num_points); + points_.alloc (num_points + 4); // Allocate for phantom points, to avoid a possible copy + if (!points_.resize (num_points)) return false; if (phantom_only) return true; for (int i = 0; i < num_contours; i++)