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 <info@bnoordhuis.nl>
This commit is contained in:
cjihrig 2015-01-19 13:02:18 -05:00
parent 4af5746993
commit e2558f02df

View File

@ -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);
}