From 2151ea4bd12d68bc82ee48c3de0f092d62483ddc Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 9 Aug 2020 16:50:14 -0700 Subject: [PATCH] fix: avoid accessing min/max rep on a NULL cluster When entering compile_samerank, the parent cluster could be NULL, which was then incorrectly dereferenced in the two cases affected in this change. This issue was found by Google Autofuzz project. Related to #1676. --- lib/dotgen/rank.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/dotgen/rank.c b/lib/dotgen/rank.c index 8c26d907b..e8b721d7d 100644 --- a/lib/dotgen/rank.c +++ b/lib/dotgen/rank.c @@ -836,13 +836,17 @@ static void compile_samerank(graph_t * ug, graph_t * parent_clust) GD_has_sourcerank(clust) = TRUE; /* fall through */ case MINRANK: leader = union_all(ug); - GD_minrep(clust) = union_one(leader, GD_minrep(clust)); + if (clust != NULL) { + GD_minrep(clust) = union_one(leader, GD_minrep(clust)); + } break; case SINKRANK: GD_has_sinkrank(clust) = TRUE; /* fall through */ case MAXRANK: leader = union_all(ug); - GD_maxrep(clust) = union_one(leader, GD_maxrep(clust)); + if (clust != NULL) { + GD_maxrep(clust) = union_one(leader, GD_maxrep(clust)); + } break; case SAMERANK: leader = union_all(ug); -- 2.40.0