From 7ce2555896536a6c9e96a8b9fd17b6563137a876 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 19 Aug 2017 18:29:25 +0200 Subject: stream: fix Writable instanceof for subclasses The current custom instanceof for `Writable` subclasses previously returned false positives for instances of *other* subclasses of `Writable` because it was inherited by these subclasses. Fixes: https://github.com/nodejs/node/issues/14943 PR-URL: https://github.com/nodejs/node/pull/14945 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Refael Ackermann Reviewed-By: Timothy Gu Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- lib/_stream_writable.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 6e0eaf45b5..7de77958d5 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -179,6 +179,8 @@ if (typeof Symbol === 'function' && Symbol.hasInstance) { value: function(object) { if (realHasInstance.call(this, object)) return true; + if (this !== Writable) + return false; return object && object._writableState instanceof WritableState; } -- cgit v1.2.3