diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 66c07e54b..aac2fbee7 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -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. diff --git a/test/fuzzing/graphs/leak-a77f29b25edb873729f3ab120148fdb213cfa527 b/test/fuzzing/graphs/leak-a77f29b25edb873729f3ab120148fdb213cfa527 new file mode 100644 index 000000000..58b4075ad Binary files /dev/null and b/test/fuzzing/graphs/leak-a77f29b25edb873729f3ab120148fdb213cfa527 differ