From 4020c6b286a5a2bacf8ca97a402b39bbf29f18c6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Jun 2020 21:59:46 -0700 Subject: [PATCH] m[blob] An empty blob can always be made writable --- src/hb-blob.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 17aa4f44d..38f4a6a40 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -365,10 +365,9 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length) char * hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) { - if (!blob->try_make_writable ()) { - if (length) - *length = 0; - + if (!blob->try_make_writable ()) + { + if (length) *length = 0; return nullptr; } @@ -443,6 +442,9 @@ hb_blob_t::try_make_writable () if (hb_object_is_immutable (this)) return false; + if (unlikely (!length)) + mode = HB_MEMORY_MODE_WRITABLE; + if (this->mode == HB_MEMORY_MODE_WRITABLE) return true;