[serialize] Add ran_out_of_room
This commit is contained in:
parent
a7c63cd8f8
commit
fe05e48086
|
@ -51,6 +51,7 @@ struct hb_serialize_context_t
|
|||
void reset ()
|
||||
{
|
||||
this->successful = true;
|
||||
this->ran_out_of_room = false;
|
||||
this->head = this->start;
|
||||
this->debug_depth = 0;
|
||||
}
|
||||
|
@ -111,7 +112,11 @@ struct hb_serialize_context_t
|
|||
template <typename Type>
|
||||
Type *allocate_size (unsigned int size)
|
||||
{
|
||||
if (unlikely (!this->successful || this->end - this->head < ptrdiff_t (size))) {
|
||||
if (unlikely (!this->successful)) return nullptr;
|
||||
|
||||
if (this->end - this->head < ptrdiff_t (size))
|
||||
{
|
||||
this->ran_out_of_room = true;
|
||||
this->successful = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -190,6 +195,7 @@ struct hb_serialize_context_t
|
|||
unsigned int debug_depth;
|
||||
char *start, *end, *head;
|
||||
bool successful;
|
||||
bool ran_out_of_room;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ _subset2 (hb_subset_plan_t *plan)
|
|||
hb_serialize_context_t serializer ((void *) buf, buf_size);
|
||||
hb_subset_context_t c (plan, &serializer);
|
||||
result = table->subset (&c);
|
||||
if (serializer.in_error ())
|
||||
if (serializer.ran_out_of_room)
|
||||
{
|
||||
buf_size += (buf_size >> 1) + 32;
|
||||
DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG (tag), buf_size);
|
||||
|
@ -94,6 +94,11 @@ _subset2 (hb_subset_plan_t *plan)
|
|||
}
|
||||
goto retry;
|
||||
}
|
||||
if (serializer.in_error ())
|
||||
{
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
hb_blob_t *dest_blob = serializer.copy_blob ();
|
||||
|
|
Loading…
Reference in New Issue