[repacker] ensure link obj indices are valid.

This commit is contained in:
Garret Rieger 2022-12-01 22:12:59 +00:00
parent 554ed06fac
commit 30e405e470
2 changed files with 9 additions and 2 deletions

View File

@ -50,11 +50,18 @@ struct graph_t
unsigned priority = 0;
bool link_positions_valid ()
bool link_positions_valid (unsigned num_objects)
{
hb_set_t assigned_bytes;
for (const auto& l : obj.real_links)
{
if (l.objidx >= num_objects)
{
DEBUG_MSG (SUBSET_REPACK, nullptr,
"Invalid graph. Invalid object index.");
return false;
}
unsigned start = l.position;
unsigned end = start + l.width - 1;
@ -333,7 +340,7 @@ struct graph_t
if (check_success (!vertices_.in_error ()))
v->obj = *objects[i];
check_success (v->link_positions_valid ());
check_success (v->link_positions_valid (objects.length));
if (!removed_nil) continue;
// Fix indices to account for removed nil object.