Skip to content

Commit befce3f

Browse files
authored
fix crash with -test (slackhq#602)
When running in `-test` mode, `tun` is set to nil. So we should move the defer into the `!configTest` if block. panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x54855c] goroutine 1 [running]: github.com/slackhq/nebula.Main.func3(0x4000135e80, {0x0, 0x0}) github.com/slackhq/nebula/main.go:176 +0x2c github.com/slackhq/nebula.Main(0x400022e060, 0x1, {0x76faa0, 0x5}, 0x4000230000, 0x0) github.com/slackhq/nebula/main.go:316 +0x2414 main.main() github.com/slackhq/nebula/cmd/nebula/main.go:54 +0x540
1 parent f60ed2b commit befce3f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
138138
if err != nil {
139139
return nil, util.NewContextualError("Failed to get a tun/tap device", nil, err)
140140
}
141-
}
142141

143-
defer func() {
144-
if reterr != nil {
145-
tun.Close()
146-
}
147-
}()
142+
defer func() {
143+
if reterr != nil {
144+
tun.Close()
145+
}
146+
}()
147+
}
148148

149149
// set up our UDP listener
150150
udpConns := make([]*udp.Conn, routines)

0 commit comments

Comments
 (0)