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.
This commit is contained in:
parent
4b6e956a2d
commit
78397eda9b
1 changed files with 15 additions and 0 deletions
15
src/edge.c
15
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue