From f4bc7673db762db8dbb83caaeeb32b2c04dbcf9a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 15 Mar 2021 14:54:45 -0600 Subject: [PATCH] [buffer] Implement copy_glyph() in terms of output_info() --- src/hb-buffer.hh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 7b4e92985..dac2a461d 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -255,13 +255,11 @@ struct hb_buffer_t /* Copies glyph at idx to output but doesn't advance idx */ HB_NODISCARD bool copy_glyph () { - if (unlikely (!make_room_for (0, 1))) return false; - - out_info[out_len] = info[idx]; - - out_len++; - return true; + /* Extra copy because cur()'s return can be freed within + * output_info() call if buffer reallocates. */ + return output_info (hb_glyph_info_t (cur())); } + /* Copies glyph at idx to output and advance idx. * If there's no output, just advance idx. */ bool next_glyph ()