Fixed CID-11002: Dereference after null check

Make sure we have a connection before comparing the sockets