From 5e76ddf54d288aa92082513caa10b9212a60ec31 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Jun 2020 20:46:02 -0700 Subject: [PATCH] m[buffer] In hb_buffer_append() don't change until allocation success --- src/hb-buffer.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 11826b16d..3c54f7243 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -1772,11 +1772,6 @@ hb_buffer_append (hb_buffer_t *buffer, if (start == end) return; - if (!buffer->len) - buffer->content_type = source->content_type; - if (!buffer->have_positions && source->have_positions) - buffer->clear_positions (); - if (buffer->len + (end - start) < buffer->len) /* Overflows. */ { buffer->successful = false; @@ -1788,6 +1783,11 @@ hb_buffer_append (hb_buffer_t *buffer, if (unlikely (!buffer->successful)) return; + if (!orig_len) + buffer->content_type = source->content_type; + if (!buffer->have_positions && source->have_positions) + buffer->clear_positions (); + memcpy (buffer->info + orig_len, source->info + start, (end - start) * sizeof (buffer->info[0])); if (buffer->have_positions) memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0]));