]> git.meshlink.io Git - meshlink/commitdiff
Fix potential segmentation fault on node reachability change.
authorGuus Sliepen <guus@meshlink.io>
Fri, 19 Jul 2019 12:40:36 +0000 (14:40 +0200)
committerGuus Sliepen <guus@meshlink.io>
Fri, 19 Jul 2019 12:40:36 +0000 (14:40 +0200)
src/graph.c

index 8e39b98d62f7e0c0167ad36b4fa697c2e7864cd2..d779ecd5f4144b2d6c92be41155924b5dbe56d02 100644 (file)
@@ -237,13 +237,14 @@ static void check_reachability(meshlink_handle_t *mesh) {
                                update_node_udp(mesh, n, NULL);
                                n->status.broadcast = false;
                                n->options = 0;
-                               utcp_offline(n->utcp, true);
                        } else if(n->connection) {
                                if(n->connection->outgoing) {
                                        send_req_key(mesh, n);
                                }
+                       }
 
-                               utcp_offline(n->utcp, false);
+                       if(n->utcp) {
+                               utcp_offline(n->utcp, !n->status.reachable);
                        }
                }
        }