From df0620e4a09f65c77e98d90309f6860dbcc399a8 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 9 Sep 2016 19:45:43 +0000 Subject: [PATCH] lib: Add nullcheck before graph node deletion Signed-off-by: Quentin Young --- lib/graph.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/graph.c b/lib/graph.c index 314cf86850..18f32b8ca2 100644 --- a/lib/graph.c +++ b/lib/graph.c @@ -62,6 +62,7 @@ graph_delete_node (struct graph *graph, struct graph_node *node) for (unsigned int i = 0; i < vector_active (node->from); i++) { adj = vector_slot (node->from, i); + if (!adj) continue; for (unsigned int j = 0; j < vector_active (adj->to); j++) if (vector_slot (adj->to, j) == node) vector_unset (adj->to, j); @@ -71,6 +72,7 @@ graph_delete_node (struct graph *graph, struct graph_node *node) for (unsigned int i = 0; i < vector_active (node->to); i++) { adj = vector_slot (node->to, i); + if (!adj) continue; for (unsigned int j = 0; j < vector_active (adj->from); j++) if (vector_slot (adj->from, j) == node) vector_unset (adj->from, j); -- 2.39.5