CID-11036: Fix memory leak when we can't connect to a server
Merged Pull Request #487

* pull-request/487:
  CID-11036: Fix memory leak when we can't connect to a server