m[blob] An empty blob can always be made writable

This commit is contained in:
Behdad Esfahbod 2020-06-28 21:59:46 -07:00
parent 2d39031f7b
commit 4020c6b286
1 changed files with 6 additions and 4 deletions

View File

@ -365,10 +365,9 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
char * char *
hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
{ {
if (!blob->try_make_writable ()) { if (!blob->try_make_writable ())
if (length) {
*length = 0; if (length) *length = 0;
return nullptr; return nullptr;
} }
@ -443,6 +442,9 @@ hb_blob_t::try_make_writable ()
if (hb_object_is_immutable (this)) if (hb_object_is_immutable (this))
return false; return false;
if (unlikely (!length))
mode = HB_MEMORY_MODE_WRITABLE;
if (this->mode == HB_MEMORY_MODE_WRITABLE) if (this->mode == HB_MEMORY_MODE_WRITABLE)
return true; return true;