net: fix abort on bad address input · nodejs/node@792acc1

Original file line numberDiff line numberDiff line change

@@ -912,8 +912,9 @@ Socket.prototype.connect = function(options, cb) {

912912

this._sockname = null;

913913

}

914914
915-

var pipe = !!options.path;

916-

debug('pipe', pipe, options.path);

915+

const path = options.path;

916+

var pipe = !!path;

917+

debug('pipe', pipe, path);

917918
918919

if (!this._handle) {

919920

this._handle = pipe ? new Pipe() : new TCP();

@@ -930,7 +931,10 @@ Socket.prototype.connect = function(options, cb) {

930931

this.writable = true;

931932
932933

if (pipe) {

933-

connect(this, options.path);

934+

if (typeof path !== 'string') {

935+

throw new TypeError('"path" option must be a string: ' + path);

936+

}

937+

connect(this, path);

934938

} else {

935939

lookupAndConnect(this, options);

936940

}