Fix potential memory leak

Delete the socket if the initialization part of the socket creation
fails.