[serialize] Support zerocopy while sharing
diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh
index 9aeed14..d557328 100644
--- a/src/hb-serialize.hh
+++ b/src/hb-serialize.hh
@@ -348,8 +348,8 @@
assert (obj->head <= obj->tail);
unsigned len = obj->tail - obj->head;
head = zerocopy ? zerocopy : obj->head; /* Rewind head. */
- if (zerocopy)
- assert (!share);
+ bool was_zerocopy = zerocopy;
+ zerocopy = nullptr;
if (!len)
{
@@ -373,11 +373,8 @@
}
tail -= len;
- if (zerocopy)
- {
- zerocopy = nullptr;
+ if (was_zerocopy)
assert (tail == obj->head);
- }
else
memmove (tail, obj->head, len);