summaryrefslogtreecommitdiff
path: root/lib/dgram.js
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-02-08 16:02:33 +0200
committercjihrig <cjihrig@gmail.com>2017-02-16 12:24:07 -0500
commitadf1ed01463a66043ab8e912742f0f1765b45bfd (patch)
tree66de24fcf897ac7043e0c80f7ce89519237c9f2f /lib/dgram.js
parent5ba00af2170e58e29ac985038b335253fdd39d9f (diff)
downloadandroid-node-v8-adf1ed01463a66043ab8e912742f0f1765b45bfd.tar.gz
android-node-v8-adf1ed01463a66043ab8e912742f0f1765b45bfd.tar.bz2
android-node-v8-adf1ed01463a66043ab8e912742f0f1765b45bfd.zip
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: https://github.com/nodejs/node/issues/10323 PR-URL: https://github.com/nodejs/node/pull/11242 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/dgram.js')
-rw-r--r--lib/dgram.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/dgram.js b/lib/dgram.js
index 4934900973..bba9889678 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -131,7 +131,7 @@ function replaceHandle(self, newHandle) {
self._handle = newHandle;
}
-Socket.prototype.bind = function(port_ /*, address, callback*/) {
+Socket.prototype.bind = function(port_, address_ /*, callback*/) {
let port = port_;
this._healthCheck();
@@ -141,7 +141,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) {
this._bindState = BIND_STATE_BINDING;
- if (typeof arguments[arguments.length - 1] === 'function')
+ if (arguments.length && typeof arguments[arguments.length - 1] === 'function')
this.once('listening', arguments[arguments.length - 1]);
if (port instanceof UDP) {
@@ -158,7 +158,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) {
exclusive = !!port.exclusive;
port = port.port;
} else {
- address = typeof arguments[1] === 'function' ? '' : arguments[1];
+ address = typeof address_ === 'function' ? '' : address_;
exclusive = false;
}