m[buffer] In hb_buffer_append() don't change until allocation success

This commit is contained in:
Behdad Esfahbod 2020-06-28 20:46:02 -07:00
parent 0f61a6213a
commit 21433fa563
1 changed files with 5 additions and 5 deletions

View File

@ -1772,11 +1772,6 @@ hb_buffer_append (hb_buffer_t *buffer,
if (start == end) if (start == end)
return; 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. */ if (buffer->len + (end - start) < buffer->len) /* Overflows. */
{ {
buffer->successful = false; buffer->successful = false;
@ -1788,6 +1783,11 @@ hb_buffer_append (hb_buffer_t *buffer,
if (unlikely (!buffer->successful)) if (unlikely (!buffer->successful))
return; 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])); memcpy (buffer->info + orig_len, source->info + start, (end - start) * sizeof (buffer->info[0]));
if (buffer->have_positions) if (buffer->have_positions)
memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0])); memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0]));