[subset] cleanup memory leaks in the repacker.

This commit is contained in:
Garret Rieger 2020-11-09 16:52:36 -08:00
parent a7a86a6eb4
commit 6e9468fcfb
2 changed files with 14 additions and 5 deletions

View File

@ -77,6 +77,7 @@ struct graph_t
// TODO(garretrieger): once priority is high enough, should try // TODO(garretrieger): once priority is high enough, should try
// setting distance = 0 which will force to sort immediately after // setting distance = 0 which will force to sort immediately after
// it's parent where possible. // it's parent where possible.
int64_t modified_distance = distance + distance_modifier (); int64_t modified_distance = distance + distance_modifier ();
return (modified_distance << 24) | (0x00FFFFFF & order); return (modified_distance << 24) | (0x00FFFFFF & order);
} }
@ -254,6 +255,8 @@ struct graph_t
remap_obj_indices (id_map, &sorted_graph); remap_obj_indices (id_map, &sorted_graph);
sorted_graph.as_array ().reverse (); sorted_graph.as_array ().reverse ();
vertices_.fini_deep ();
vertices_ = sorted_graph; vertices_ = sorted_graph;
sorted_graph.fini_deep (); sorted_graph.fini_deep ();
} }
@ -319,6 +322,8 @@ struct graph_t
remap_obj_indices (id_map, &sorted_graph); remap_obj_indices (id_map, &sorted_graph);
sorted_graph.as_array ().reverse (); sorted_graph.as_array ().reverse ();
vertices_.fini_deep ();
vertices_ = sorted_graph; vertices_ = sorted_graph;
sorted_graph.fini_deep (); sorted_graph.fini_deep ();
} }
@ -335,11 +340,11 @@ struct graph_t
positions_invalid = true; positions_invalid = true;
auto* clone = vertices_.push ();
auto& child = vertices_[child_idx]; auto& child = vertices_[child_idx];
clone_buffer_t* buffer = clone_buffers_.push (); clone_buffer_t* buffer = clone_buffers_.push ();
buffer->copy (child.obj); buffer->copy (child.obj);
auto* clone = vertices_.push ();
clone->obj.head = buffer->head; clone->obj.head = buffer->head;
clone->obj.tail = buffer->tail; clone->obj.tail = buffer->tail;
clone->distance = child.distance; clone->distance = child.distance;

View File

@ -142,10 +142,14 @@ _subset (hb_subset_plan_t *plan)
if (needed) if (needed)
{ {
hb_blob_t *dest_blob = _repack (tag, serializer); hb_blob_t *dest_blob = _repack (tag, serializer);
if (!dest_blob) return false; if (dest_blob)
DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG (tag), dest_blob->length); {
result = c.plan->add_table (tag, dest_blob); DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG (tag), dest_blob->length);
hb_blob_destroy (dest_blob); result = c.plan->add_table (tag, dest_blob);
hb_blob_destroy (dest_blob);
} else {
result = false;
}
} }
else else
{ {