diff --git a/lib/dns.js b/lib/dns.js index dfe37dffd2..b891c79d52 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -102,17 +102,14 @@ function onlookup(err, addresses) { // lookup(hostname, [options,] callback) exports.lookup = function lookup(hostname, options, callback) { var hints = 0; - var family; + var family = 0; // Parse arguments if (typeof options === 'function') { callback = options; family = 0; - // Allow user to pass falsy values to options, and still pass callback. } else if (typeof callback !== 'function') { throw TypeError('invalid arguments: callback must be passed'); - } else if (!options) { - family = 0; } else if (util.isObject(options)) { hints = options.hints >>> 0; family = options.family >>> 0; @@ -123,8 +120,6 @@ exports.lookup = function lookup(hostname, options, callback) { hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) { throw new TypeError('invalid argument: hints must use valid flags'); } - } else { - family = options >>> 0; } if (family !== 0 && family !== 4 && family !== 6) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index af72c49595..f3911df5ce 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1014,12 +1014,11 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { assert(args[0]->IsObject()); assert(args[1]->IsString()); assert(args[2]->IsInt32()); - assert(args[3]->IsInt32()); Local req_wrap_obj = args[0].As(); node::Utf8Value hostname(args[1]); + int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0; int family; - int32_t flags = args[3]->Int32Value(); switch (args[2]->Int32Value()) { case 0: