From c55c01977101f999145594b950d4ea802e723ce7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 21 Mar 2022 19:11:17 -0600 Subject: [PATCH] [buffer] Add assertions of buffer sync status to message_impl --- src/hb-buffer.cc | 10 +++++++++- src/hb-buffer.hh | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index e09dee77f..83cd3dca8 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -2116,8 +2116,16 @@ hb_buffer_set_message_func (hb_buffer_t *buffer, bool hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap) { + assert (!have_output || (out_info == info && out_len == idx)); + + message_depth++; + char buf[100]; vsnprintf (buf, sizeof (buf), fmt, ap); - return (bool) this->message_func (this, font, buf, this->message_data); + bool ret = (bool) this->message_func (this, font, buf, this->message_data); + + message_depth--; + + return ret; } #endif diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 5ad273ce8..1b89a32db 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -556,15 +556,11 @@ struct hb_buffer_t if (likely (!messaging ())) return true; - message_depth++; - va_list ap; va_start (ap, fmt); bool ret = message_impl (font, fmt, ap); va_end (ap); - message_depth--; - return ret; #endif }