From 82928d9cf65e275362188e9d855690d2ae71f005 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Jun 2020 22:03:57 -0700 Subject: [PATCH] m[blob] Move immutable check to C API boundary Similarly to 08ed9e3f779253e3b5f01c38d44d0e5db2d5e7aa --- src/hb-blob.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 38f4a6a40..49b41e180 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -365,15 +365,14 @@ 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 (hb_object_is_immutable (blob) || + !blob->try_make_writable ()) { if (length) *length = 0; return nullptr; } - if (length) - *length = blob->length; - + if (length) *length = blob->length; return const_cast (blob->data); } @@ -439,9 +438,6 @@ hb_blob_t::try_make_writable_inplace () bool hb_blob_t::try_make_writable () { - if (hb_object_is_immutable (this)) - return false; - if (unlikely (!length)) mode = HB_MEMORY_MODE_WRITABLE;