diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-08-13 22:28:17 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-08-13 22:28:17 +0000 |
commit | df2e2e3f15b4285d232fbd5c6583458e0f15d496 (patch) | |
tree | 1ad6bb707940a5c0f7fcf2c1054253a2ee73cf0c /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh | |
parent | f44080f58b866fbc798cda2e0f9eb9f7c4ed943d (diff) |
harfbuzz-2.7.1
git-svn-id: svn://tug.org/texlive/trunk@56107 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh index 4fb4f4ef40a..4566153a593 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-serialize.hh @@ -172,6 +172,8 @@ struct hb_serialize_context_t propagate_error (packed, packed_map); if (unlikely (!current)) return; + if (unlikely (in_error())) return; + assert (!current->next); /* Only "pack" if there exist other objects... Otherwise, don't bother. @@ -187,6 +189,8 @@ struct hb_serialize_context_t template <typename Type = void> Type *push () { + if (unlikely (in_error ())) return start_embed<Type> (); + object_t *obj = object_pool.alloc (); if (unlikely (!obj)) check_success (false); @@ -203,6 +207,8 @@ struct hb_serialize_context_t { object_t *obj = current; if (unlikely (!obj)) return; + if (unlikely (in_error())) return; + current = current->next; revert (obj->head, obj->tail); obj->fini (); @@ -217,6 +223,8 @@ struct hb_serialize_context_t { object_t *obj = current; if (unlikely (!obj)) return 0; + if (unlikely (in_error())) return 0; + current = current->next; obj->tail = head; obj->next = nullptr; @@ -248,25 +256,34 @@ struct hb_serialize_context_t packed.push (obj); - if (unlikely (packed.in_error ())) + if (unlikely (packed.in_error ())) { + // obj wasn't successfully added to packed, so clean it up otherwise it's + // links will be leaked. + propagate_error (packed); + obj->fini (); return 0; + } objidx = packed.length - 1; if (share) packed_map.set (obj, objidx); + propagate_error (packed_map); return objidx; } void revert (snapshot_t snap) { + if (unlikely (in_error ())) return; assert (snap.current == current); current->links.shrink (snap.num_links); revert (snap.head, snap.tail); } + void revert (char *snap_head, char *snap_tail) { + if (unlikely (in_error ())) return; assert (snap_head <= head); assert (tail <= snap_tail); head = snap_head; @@ -276,6 +293,7 @@ struct hb_serialize_context_t void discard_stale_objects () { + if (unlikely (in_error ())) return; while (packed.length > 1 && packed.tail ()->head < tail) { @@ -294,6 +312,7 @@ struct hb_serialize_context_t unsigned bias = 0) { static_assert (sizeof (T) == 2 || sizeof (T) == 4, ""); + if (unlikely (in_error ())) return; if (!objidx) return; @@ -313,6 +332,7 @@ struct hb_serialize_context_t unsigned to_bias (const void *base) const { + if (unlikely (in_error ())) return 0; if (!base) return 0; assert (current); assert (current->head <= (const char *) base); @@ -357,7 +377,11 @@ struct hb_serialize_context_t } } - unsigned int length () const { return this->head - current->head; } + unsigned int length () const + { + if (unlikely (!current)) return 0; + return this->head - current->head; + } void align (unsigned int alignment) { @@ -445,6 +469,8 @@ struct hb_serialize_context_t template <typename Type> Type *extend_size (Type *obj, unsigned int size) { + if (unlikely (in_error ())) return nullptr; + assert (this->start <= (char *) obj); assert ((char *) obj <= this->head); assert ((char *) obj + size >= this->head); |