Permalink
Browse files

util: ensure that the .inspect function isn't the one being executed

Fixes #2225.
  • Loading branch information...
1 parent 754e23d commit b204006105e556be07121abd52e5cf0da3d3d8ae @TooTallNate TooTallNate committed with bnoordhuis Nov 30, 2011
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/util.js
  2. +4 −0 test/simple/test-util-inspect.js
View
@@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) {
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
- value !== exports &&
+ value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
@@ -75,3 +75,7 @@ assert.doesNotThrow(function () {
r.toString = null;
util.inspect(r);
});
+
+// GH-2225
+var x = { inspect: util.inspect };
+assert.ok(util.inspect(x).indexOf('inspect') != -1);

0 comments on commit b204006

Please sign in to comment.