]> git.meshlink.io Git - meshlink/blobdiff - src/net_setup.c
Fix a crash when meshlink_open() is called with an invalid confbase.
[meshlink] / src / net_setup.c
index 8b0fd8fde443ced49bb80905bf7df3459ded601c..ce9a59ad230b0723e5bafeed12f312fed629b4a5 100644 (file)
@@ -377,11 +377,13 @@ bool setup_network(meshlink_handle_t *mesh) {
   close all open network connections
 */
 void close_network_connections(meshlink_handle_t *mesh) {
-       for(list_node_t *node = mesh->connections->head, *next; node; node = next) {
-               next = node->next;
-               connection_t *c = node->data;
-               c->outgoing = NULL;
-               terminate_connection(mesh, c, false);
+       if(mesh->connections) {
+               for(list_node_t *node = mesh->connections->head, *next; node; node = next) {
+                       next = node->next;
+                       connection_t *c = node->data;
+                       c->outgoing = NULL;
+                       terminate_connection(mesh, c, false);
+               }
        }
 
        if(mesh->outgoings)