From 8f5d8b155c0cbf9f61cf6a23d73dbc7130df21e0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 9 Oct 2020 17:58:57 -0600 Subject: [PATCH] [buffer] Buffer start <= end <= len requirement in (de-)serialize --- src/hb-buffer-serialize.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hb-buffer-serialize.cc b/src/hb-buffer-serialize.cc index 37bdcd601..aac2eb10d 100644 --- a/src/hb-buffer-serialize.cc +++ b/src/hb-buffer-serialize.cc @@ -464,7 +464,8 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer, hb_buffer_serialize_format_t format, hb_buffer_serialize_flags_t flags) { - assert (start <= end && end <= buffer->len); + end = hb_clamp (end, start, buffer->len); + start = hb_min (start, end); unsigned int sconsumed; if (!buf_consumed) @@ -561,7 +562,8 @@ hb_buffer_serialize_unicode (hb_buffer_t *buffer, hb_buffer_serialize_format_t format, hb_buffer_serialize_flags_t flags) { - assert (start <= end && end <= buffer->len); + end = hb_clamp (end, start, buffer->len); + start = hb_min (start, end); unsigned int sconsumed; if (!buf_consumed)