net: Prevent property access throws during close
authorReid Burke <me@reidburke.com>
Sat, 16 Jun 2012 01:52:31 +0000 (20:52 -0500)
committerisaacs <i@izs.me>
Sun, 17 Jun 2012 20:00:00 +0000 (13:00 -0700)
commit71a2a2caa69865add8065cb0e282096e3f4d78f6
treee86b165f0c7ec5b8c697f702fccceb1628cff02e
parentb0b707cb6e48fd0393c24c80c9fe490855d24f84
net: Prevent property access throws during close

Fix #3455.

The remoteAddress and remotePort properties are
dynamically retrieved from _getpeername().

While _getpeername() checks if the _handle is
null, it is also possible for the tcp_wrapped
_handle.getpeername() to return null on error.

Such a condition happens when the remote closes
and one of these properties is accessed before
_handle is set to null.
lib/net.js
test/simple/test-net-during-close.js [new file with mode: 0644]