CA-148234: Don't leak socket if fixing cookie fails

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>