Skip to content

Commit aef67cf

Browse files
vsemozhetbytItalo A. Casas
authored andcommitted
dgram: fix possibly deoptimizing use of arguments
This commit adds a guard against an out of bounds access of arguments, and replaces another use of arguments with a named function parameter. Refs: #10323 PR-URL: #11242 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5f1a568 commit aef67cf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎lib/dgram.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function replaceHandle(self, newHandle){
131131
self._handle=newHandle;
132132
}
133133

134-
Socket.prototype.bind=function(port_/*, address, callback*/){
134+
Socket.prototype.bind=function(port_,address_/*, callback*/){
135135
letport=port_;
136136

137137
this._healthCheck();
@@ -141,7 +141,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/){
141141

142142
this._bindState=BIND_STATE_BINDING;
143143

144-
if(typeofarguments[arguments.length-1]==='function')
144+
if(arguments.length&&typeofarguments[arguments.length-1]==='function')
145145
this.once('listening',arguments[arguments.length-1]);
146146

147147
if(portinstanceofUDP){
@@ -158,7 +158,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/){
158158
exclusive=!!port.exclusive;
159159
port=port.port;
160160
}else{
161-
address=typeofarguments[1]==='function' ? '' : arguments[1];
161+
address=typeofaddress_==='function' ? '' : address_;
162162
exclusive=false;
163163
}
164164

0 commit comments

Comments
(0)