From 02c6c8cd6e8c93b63c75b25de6bf76bb45755bb4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 15 Nov 2013 13:05:38 -0500 Subject: [PATCH] Set buffer content type to INVALID in hb_buffer_set_length(0) Previously we were only setting this in hb_buffer_clear_contents(), but set_length(0) is a valid way to reinitialize buffer to use with new text. --- src/hb-buffer-private.hh | 2 +- src/hb-buffer.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index d3ed4491..49773f1c 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -181,7 +181,7 @@ struct hb_buffer_t { HB_INTERNAL bool enlarge (unsigned int size); inline bool ensure (unsigned int size) - { return likely (size < allocated) ? true : enlarge (size); } + { return likely (!size || size < allocated) ? true : enlarge (size); } HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); HB_INTERNAL bool shift_forward (unsigned int count); diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index bbf8ea0f..d6c6fcb8 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -1150,7 +1150,10 @@ hb_buffer_set_length (hb_buffer_t *buffer, buffer->len = length; if (!length) + { + buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; buffer->clear_context (0); + } buffer->clear_context (1); return true; -- GitLab