From 78397eda9bb6e9a334290a09433105195394e520 Mon Sep 17 00:00:00 2001 From: thorkill Date: Thu, 2 Jul 2015 00:02:05 +0200 Subject: [PATCH] Added extra check for edge->from and edge->to in edge_add edge_add() and edge_del() assume, that from and to are always set. This was triggered while working on cmocka test. --- src/edge.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/edge.c b/src/edge.c index e98f4fcd..6ad1b74a 100644 --- a/src/edge.c +++ b/src/edge.c @@ -83,6 +83,16 @@ void free_edge(edge_t *e) { void edge_add(edge_t *e) { splay_insert(edge_weight_tree, e); + if (!e->from) { + logger(DEBUG_ALWAYS, LOG_ERR, "edge_add(): e->from is NULL!"); + abort(); + } + + if (!e->to) { + logger(DEBUG_ALWAYS, LOG_ERR, "edge_add(): e->to is NULL!"); + abort(); + } + splay_insert(e->from->edge_tree, e); e->reverse = lookup_edge(e->to, e->from); @@ -96,6 +106,11 @@ void edge_del(edge_t *e) { e->reverse->reverse = NULL; splay_delete(edge_weight_tree, e); + if (!e->from) { + logger(DEBUG_ALWAYS, LOG_ERR, "edge_del(): e->from is NULL!"); + abort(); + } + splay_delete(e->from->edge_tree, e); }