go/neo/neonet: Fix segmentation violation in case handshake fails
Because 'err' was locally assigned inside the loop of 'DialLink' [1], it was always 'nil' as a function return value, even when 'handshakeClient' actually returned an error. This lead to the unfortunate situation that the function sometimes returned 'link=nil' and 'err=nil', so that the function caller tried to access 'link' attributes which lead to 'runtime error: invalid memory address or nil pointer dereference'. This patch fixes this and now the function correctly returns an error if the dialing fails. [1] `peerConn, err := networker.Dial(ctx, addr)`
Showing
Please register or sign in to comment