From e2558f02dfb671fc74f5768d4401a826efb5c117 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 19 Jan 2015 13:02:18 -0500 Subject: [PATCH] net: fix error details in connect() 3ac494195319efb9c923c0ee89b6e0f2617d53ef introduced a bug as it attempted to access properties of an undefined variable. This commit cleans up the offending code. Fixes: https://github.com/iojs/io.js/issues/510 PR-URL: https://github.com/iojs/io.js/pull/514 Reviewed-By: Ben Noordhuis --- lib/net.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/net.js b/lib/net.js index 2a3934729a9ef3..85789c365a1785 100644 --- a/lib/net.js +++ b/lib/net.js @@ -813,13 +813,13 @@ function connect(self, address, port, addressType, localAddress, localPort) { } if (err) { - self._getsockname(); + var sockname = self._getsockname(); var details; - if (self._sockname) { - ex.localAddress = self._sockname.address; - ex.localPort = self._sockname.port; - details = ex.localAddress + ':' + ex.localPort; + + if (sockname) { + details = sockname.address + ':' + sockname.port; } + var ex = exceptionWithHostPort(err, 'connect', address, port, details); self._destroy(ex); }