Check if devops is valid before closing the device.
authorEtienne Dechamps <etienne@edechamps.fr>
Sat, 12 Jul 2014 12:56:01 +0000 (13:56 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 12 Jul 2014 12:56:01 +0000 (13:56 +0100)
This fixes a segfault that occurs on exit if tinc fails before the
device is initialized (for example, if it fails to read the private
key).

src/net_setup.c

index 96a7224..d83c572 100644 (file)
@@ -1141,7 +1141,8 @@ void close_network_connections(void) {
 
        if (device_fd >= 0)
                io_del(&device_io);
 
        if (device_fd >= 0)
                io_del(&device_io);
-       devops.close();
+       if (devops.close)
+               devops.close();
 
        exit_control();
 
 
        exit_control();