From 743671278f9cfdc1ea10e58762abbd4ea19c7963 Mon Sep 17 00:00:00 2001
From: thorkill <thkr@hannover.ccc.de>
Date: Thu, 2 Jul 2015 20:38:02 +0200
Subject: [PATCH] Attempt to track an segfault in mst_kruskal()

(gdb) bt
#0  mst_kruskal () at graph.c:107
#1  graph () at graph.c:302
#2  0x00007ffff7b509fe in del_edge_h (c=<optimized out>, request=<optimized out>) at protocol_edge.c:292
#3  0x00007ffff7b4de2e in receive_request (c=0x5555557e3ef0, request=0x555555800e13 "13 3fc17404 node1 node2") at protocol.c:136
#4  0x00007ffff7b43513 in receive_meta (c=0x5555557e3ef0) at meta.c:290
#5  0x00007ffff7b442d9 in handle_meta_connection_data (c=0x5555557e3ef0) at net.c:291
#6  0x00007ffff7b41391 in event_loop () at event.c:287
#7  0x00007ffff7b449b2 in main_loop () at net.c:469
#8  0x0000555555556716 in main (argc=<optimized out>, argv=<optimized out>) at tincd.c:480
---
 src/graph.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/graph.c b/src/graph.c
index 333f5840..dca3b057 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -92,6 +92,17 @@ static void mst_kruskal(void) {
 	bool skipped = false;
 
 	for splay_each(edge_t, e, edge_weight_tree) {
+			if (!e->from) {
+				logger(DEBUG_ALWAYS, LOG_ERR, "current edge doesn't have from! - should abort");
+				skipped = true;
+				continue;
+			}
+			if (!e->to) {
+				logger(DEBUG_ALWAYS, LOG_ERR, "current edge doesn't have to! - should abort");
+				skipped = true;
+				continue;
+			}
+
 		if(!e->reverse || (e->from->status.visited == e->to->status.visited)) {
 			skipped = true;
 			continue;